windowManager: Add a generic mechanism for filtering keybindings
Currently we hardcode the set of keybindings that are available in the overview; add a generic mechanism to specify in which KeybindingModes a keybinding should be available. https://bugzilla.gnome.org/show_bug.cgi?id=688202
This commit is contained in:
parent
b58f502dd6
commit
0d9f70492e
@ -83,6 +83,8 @@ const WindowManager = new Lang.Class({
|
||||
|
||||
this._animationBlockCount = 0;
|
||||
|
||||
this._allowedKeybindings = {};
|
||||
|
||||
this._switchData = null;
|
||||
this._shellwm.connect('kill-switch-workspace', Lang.bind(this, this._switchWorkspaceDone));
|
||||
this._shellwm.connect('kill-window-effects', Lang.bind(this, function (shellwm, actor) {
|
||||
@ -143,6 +145,25 @@ const WindowManager = new Lang.Class({
|
||||
}));
|
||||
},
|
||||
|
||||
setCustomKeybindingHandler: function(name, modes, handler) {
|
||||
if (Meta.keybindings_set_custom_handler(name, handler))
|
||||
this.allowKeybinding(name, modes);
|
||||
},
|
||||
|
||||
addKeybinding: function(name, settings, flags, modes, handler) {
|
||||
if (global.display.add_keybinding(name, settings, flags, handler))
|
||||
this.allowKeybinding(name, modes);
|
||||
},
|
||||
|
||||
removeKeybinding: function(name) {
|
||||
if (global.display.remove_keybinding(name))
|
||||
this.allowKeybinding(name, Main.KeybindingMode.NONE);
|
||||
},
|
||||
|
||||
allowKeybinding: function(name, modes) {
|
||||
this._allowedKeybindings[name] = modes;
|
||||
},
|
||||
|
||||
blockAnimations: function() {
|
||||
this._animationBlockCount++;
|
||||
},
|
||||
@ -449,10 +470,15 @@ const WindowManager = new Lang.Class({
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Main.modalCount == 0 && binding.is_builtin())
|
||||
// There's little sense in implementing a keybinding in mutter and
|
||||
// not having it work in NORMAL mode; handle this case generically
|
||||
// so we don't have to explicitly allow all builtin keybindings in
|
||||
// NORMAL mode.
|
||||
if (Main.keybindingMode == Main.KeybindingMode.NORMAL &&
|
||||
binding.is_builtin())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return !(this._allowedKeybindings[binding.get_name()] & Main.keybindingMode);
|
||||
},
|
||||
|
||||
_switchWorkspace : function(shellwm, from, to, direction) {
|
||||
|
Loading…
Reference in New Issue
Block a user