Compare commits

...

2 Commits

Author SHA1 Message Date
Florian Müllner
c43e8f41e8 layout: Offer to enable hot corner after repeated attempts to trigger it 2019-04-29 17:33:22 +00:00
Florian Müllner
8853408748 layout: Make the hot corner optional
Whether people love or hate the hot corner depends in large extents
on hardware sensitivity and habits, which is hard to get right
universally. So bite the bullet and add an option to enable or
disable hot corners ...

https://bugzilla.gnome.org/show_bug.cgi?id=688320
2019-04-26 17:27:47 +02:00
2 changed files with 57 additions and 0 deletions

View File

@ -38,6 +38,14 @@
load all extensions regardless of the versions they claim to support. load all extensions regardless of the versions they claim to support.
</description> </description>
</key> </key>
<key name="enable-hot-corners" type="b">
<default>false</default>
<summary>Enable hot corners</summary>
<description>
If true, the overview can be accessed by moving the mouse to the
top-left corner.
</description>
</key>
<key name="favorite-apps" type="as"> <key name="favorite-apps" type="as">
<default>[ 'epiphany.desktop', 'evolution.desktop', 'rhythmbox.desktop', 'shotwell.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Software.desktop' ]</default> <default>[ 'epiphany.desktop', 'evolution.desktop', 'rhythmbox.desktop', 'shotwell.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Software.desktop' ]</default>
<summary>List of desktop file IDs for favorite applications</summary> <summary>List of desktop file IDs for favorite applications</summary>

View File

@ -6,6 +6,7 @@ const Signals = imports.signals;
const Background = imports.ui.background; const Background = imports.ui.background;
const BackgroundMenu = imports.ui.backgroundMenu; const BackgroundMenu = imports.ui.backgroundMenu;
const LoginManager = imports.misc.loginManager; const LoginManager = imports.misc.loginManager;
const MessageTray = imports.ui.messageTray;
const DND = imports.ui.dnd; const DND = imports.ui.dnd;
const Main = imports.ui.main; 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_THRESHOLD = 100; // pixels
var HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms 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) { function isPopupMetaWindow(actor) {
switch(actor.meta_window.get_window_type()) { switch(actor.meta_window.get_window_type()) {
case Meta.WindowType.DROPDOWN_MENU: case Meta.WindowType.DROPDOWN_MENU:
@ -1091,6 +1097,11 @@ var HotCorner = class HotCorner {
// multiple times due to an accidental jitter. // multiple times due to an accidental jitter.
this._entered = false; 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._monitor = monitor;
this._x = x; this._x = x;
@ -1234,10 +1245,48 @@ var HotCorner = class HotCorner {
this._animRipple(this._ripple3, 0.35, 1.0, 0.0, 0.3, 1); 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() { _toggleOverview() {
if (this._monitor.inFullscreen && !Main.overview.visible) if (this._monitor.inFullscreen && !Main.overview.visible)
return; 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()) { if (Main.overview.shouldToggleByCornerOrButton()) {
this._rippleAnimation(); this._rippleAnimation();
Main.overview.toggle(); Main.overview.toggle();