switcherPopup: Add support for modifier-less keybinding navigation
This drops the requirement that SwitcherPopups need a modifier based keybinding to work. The existing behavior for modifier based keybindings is kept but if the popup is triggered from a no modifiers keybinding, instead of finishing when the modifier is released, we use a timer that automatically finishes the popup. The timer is reset on every key release to allow navigation to happen. https://bugzilla.gnome.org/show_bug.cgi?id=783550
This commit is contained in:
parent
2339351499
commit
c899453800
@ -19,6 +19,7 @@ var POPUP_SCROLL_TIME = 0.10; // seconds
|
|||||||
var POPUP_FADE_OUT_TIME = 0.1; // seconds
|
var POPUP_FADE_OUT_TIME = 0.1; // seconds
|
||||||
|
|
||||||
var DISABLE_HOVER_TIMEOUT = 500; // milliseconds
|
var DISABLE_HOVER_TIMEOUT = 500; // milliseconds
|
||||||
|
var NO_MODS_TIMEOUT = 1500; // milliseconds
|
||||||
|
|
||||||
function mod(a, b) {
|
function mod(a, b) {
|
||||||
return (a + b) % b;
|
return (a + b) % b;
|
||||||
@ -61,6 +62,7 @@ var SwitcherPopup = new Lang.Class({
|
|||||||
|
|
||||||
this._motionTimeoutId = 0;
|
this._motionTimeoutId = 0;
|
||||||
this._initialDelayTimeoutId = 0;
|
this._initialDelayTimeoutId = 0;
|
||||||
|
this._noModsTimeoutId = 0;
|
||||||
|
|
||||||
// Initially disable hover so we ignore the enter-event if
|
// Initially disable hover so we ignore the enter-event if
|
||||||
// the switcher appears underneath the current pointer location
|
// the switcher appears underneath the current pointer location
|
||||||
@ -145,11 +147,15 @@ var SwitcherPopup = new Lang.Class({
|
|||||||
// https://bugzilla.gnome.org/show_bug.cgi?id=596695 for
|
// https://bugzilla.gnome.org/show_bug.cgi?id=596695 for
|
||||||
// details.) So we check now. (Have to do this after updating
|
// details.) So we check now. (Have to do this after updating
|
||||||
// selection.)
|
// selection.)
|
||||||
|
if (this._modifierMask) {
|
||||||
let [x, y, mods] = global.get_pointer();
|
let [x, y, mods] = global.get_pointer();
|
||||||
if (!(mods & this._modifierMask)) {
|
if (!(mods & this._modifierMask)) {
|
||||||
this._finish(global.get_current_time());
|
this._finish(global.get_current_time());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this._resetNoModsTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
// We delay showing the popup so that fast Alt+Tab users aren't
|
// We delay showing the popup so that fast Alt+Tab users aren't
|
||||||
// disturbed by the popup briefly flashing.
|
// disturbed by the popup briefly flashing.
|
||||||
@ -192,11 +198,15 @@ var SwitcherPopup = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_keyReleaseEvent: function(actor, event) {
|
_keyReleaseEvent: function(actor, event) {
|
||||||
|
if (this._modifierMask) {
|
||||||
let [x, y, mods] = global.get_pointer();
|
let [x, y, mods] = global.get_pointer();
|
||||||
let state = mods & this._modifierMask;
|
let state = mods & this._modifierMask;
|
||||||
|
|
||||||
if (state == 0)
|
if (state == 0)
|
||||||
this._finish(event.get_time());
|
this._finish(event.get_time());
|
||||||
|
} else {
|
||||||
|
this._resetNoModsTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
},
|
},
|
||||||
@ -253,6 +263,18 @@ var SwitcherPopup = new Lang.Class({
|
|||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_resetNoModsTimeout: function() {
|
||||||
|
if (this._noModsTimeoutId != 0)
|
||||||
|
Mainloop.source_remove(this._noModsTimeoutId);
|
||||||
|
|
||||||
|
this._noModsTimeoutId = Mainloop.timeout_add(NO_MODS_TIMEOUT,
|
||||||
|
Lang.bind(this, function () {
|
||||||
|
this._finish(global.get_current_time());
|
||||||
|
this._noModsTimeoutId = 0;
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
_popModal: function() {
|
_popModal: function() {
|
||||||
if (this._haveModal) {
|
if (this._haveModal) {
|
||||||
Main.popModal(this.actor);
|
Main.popModal(this.actor);
|
||||||
@ -287,6 +309,8 @@ var SwitcherPopup = new Lang.Class({
|
|||||||
Mainloop.source_remove(this._motionTimeoutId);
|
Mainloop.source_remove(this._motionTimeoutId);
|
||||||
if (this._initialDelayTimeoutId != 0)
|
if (this._initialDelayTimeoutId != 0)
|
||||||
Mainloop.source_remove(this._initialDelayTimeoutId);
|
Mainloop.source_remove(this._initialDelayTimeoutId);
|
||||||
|
if (this._noModsTimeoutId != 0)
|
||||||
|
Mainloop.source_remove(this._noModsTimeoutId);
|
||||||
},
|
},
|
||||||
|
|
||||||
_select: function(num) {
|
_select: function(num) {
|
||||||
|
Loading…
Reference in New Issue
Block a user