summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2019-04-29 17:27:39 +0000
committerFlorian Müllner <fmuellner@gnome.org>2019-04-29 17:33:22 +0000
commitc43e8f41e82cd14f84d886b4c280c0599dbffb7d (patch)
tree7dfd179acd68fdf0f3d19b7c1666ec51ac6ea761
parent8853408748e5dc592dccaf50ffd067742c091ffb (diff)
downloadgnome-shell-wip/fmuellner/opt-in-hot-corner.tar.gz
layout: Offer to enable hot corner after repeated attempts to trigger itwip/fmuellner/opt-in-hot-corner
-rw-r--r--js/ui/layout.js57
1 files changed, 49 insertions, 8 deletions
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 268321329..c4d80f22b 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -6,6 +6,7 @@ const Signals = imports.signals;
const Background = imports.ui.background;
const BackgroundMenu = imports.ui.backgroundMenu;
const LoginManager = imports.misc.loginManager;
+const MessageTray = imports.ui.messageTray;
const DND = imports.ui.dnd;
const Main = imports.ui.main;
@@ -19,6 +20,11 @@ var BACKGROUND_FADE_ANIMATION_TIME = 1.0;
var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels
var HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms
+// trigger attempts after which we offer to enable the corner
+var HOT_CORNER_TRIGGER_THRESHOLD = 2;
+// maximum time between trigger attempts
+var HOT_CORNER_TRIGGER_TIMEOUT = 1; // s
+
function isPopupMetaWindow(actor) {
switch(actor.meta_window.get_window_type()) {
case Meta.WindowType.DROPDOWN_MENU:
@@ -267,9 +273,6 @@ var LayoutManager = GObject.registerClass({
this._backgroundGroup.lower_bottom();
this._bgManagers = [];
- global.settings.connect('changed::enable-hot-corners',
- this._updateHotCorners.bind(this));
-
// Need to update struts on new workspaces when they are added
let workspaceManager = global.workspace_manager;
workspaceManager.connect('notify::n-workspaces',
@@ -373,11 +376,6 @@ var LayoutManager = GObject.registerClass({
});
this.hotCorners = [];
- if (!global.settings.get_boolean('enable-hot-corners')) {
- this.emit('hot-corners-changed');
- return;
- }
-
let size = this.panelBox.height;
// build new hot corners
@@ -1099,6 +1097,11 @@ var HotCorner = class HotCorner {
// multiple times due to an accidental jitter.
this._entered = false;
+ // Count how often the disabled hot corner would have been triggered
+ // in a particular interval; this is used to offer the user to enable
+ // the corner when passing a threshold.
+ this._triggerCount = 0;
+
this._monitor = monitor;
this._x = x;
@@ -1242,10 +1245,48 @@ var HotCorner = class HotCorner {
this._animRipple(this._ripple3, 0.35, 1.0, 0.0, 0.3, 1);
}
+ _resetTriggerTimeout() {
+ if (this._triggerTimeoutId)
+ GLib.source_remove(this._triggerTimeoutId);
+
+ this._triggerTimeoutId = GLib.timeout_add_seconds(
+ GLib.PRIORITY_DEFAULT,
+ HOT_CORNER_TRIGGER_TIMEOUT,
+ () => {
+ this._triggerCount = 0;
+
+ this._triggerTimeoutId = 0;
+ return GLib.SOURCE_REMOVE;
+ });
+ }
+
+ _showEnableNotification() {
+ let source = new MessageTray.SystemNotificationSource();
+ Main.messageTray.add(source);
+ let notification = new MessageTray.Notification(source,
+ _('Are you trying to access the activities overview?'),
+ _('GNOME can open the overview every time the pointer is moved to the corner'));
+ notification.setTransient(true);
+ notification.addAction(_('Enable corner gesture'), () => {
+ global.settings.set_boolean('enable-hot-corners', true);
+ });
+ source.notify(notification);
+}
+
_toggleOverview() {
if (this._monitor.inFullscreen && !Main.overview.visible)
return;
+ if (!global.settings.get_boolean('enable-hot-corners')) {
+ this._resetTriggerTimeout();
+ this._triggerCount++;
+
+ if (this._triggerCount >= HOT_CORNER_TRIGGER_THRESHOLD)
+ this._showEnableNotification();
+
+ return;
+ }
+
if (Main.overview.shouldToggleByCornerOrButton()) {
this._rippleAnimation();
Main.overview.toggle();