shell-wm: Remove takeover_keybinding()

Introspection support is now good enough to set a custom keybinding
handler directly from JS.

https://bugzilla.gnome.org/show_bug.cgi?id=663584
This commit is contained in:
Florian Müllner
2011-11-07 02:16:15 +01:00
parent b1064cbe50
commit d714dfd82e
4 changed files with 34 additions and 104 deletions

View File

@ -92,7 +92,6 @@ WindowManager.prototype = {
_init : function() {
this._shellwm = global.window_manager;
this._keyBindingHandlers = [];
this._minimizing = [];
this._maximizing = [];
this._unmaximizing = [];
@ -121,15 +120,24 @@ WindowManager.prototype = {
this._shellwm.connect('destroy', Lang.bind(this, this._destroyWindow));
this._workspaceSwitcherPopup = null;
this.setKeybindingHandler('switch-to-workspace-left', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch-to-workspace-right', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch-to-workspace-up', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch-to-workspace-down', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch-windows', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch-group', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch-windows-backward', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch-group-backward', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch-panels', Lang.bind(this, this._startA11ySwitcher));
Meta.keybindings_set_custom_handler('switch-to-workspace-left',
Lang.bind(this, this._showWorkspaceSwitcher));
Meta.keybindings_set_custom_handler('switch-to-workspace-right',
Lang.bind(this, this._showWorkspaceSwitcher));
Meta.keybindings_set_custom_handler('switch-to-workspace-up',
Lang.bind(this, this._showWorkspaceSwitcher));
Meta.keybindings_set_custom_handler('switch-to-workspace-down',
Lang.bind(this, this._showWorkspaceSwitcher));
Meta.keybindings_set_custom_handler('switch-windows',
Lang.bind(this, this._startAppSwitcher));
Meta.keybindings_set_custom_handler('switch-group',
Lang.bind(this, this._startAppSwitcher));
Meta.keybindings_set_custom_handler('switch-windows-backward',
Lang.bind(this, this._startAppSwitcher));
Meta.keybindings_set_custom_handler('switch-group-backward',
Lang.bind(this, this._startAppSwitcher));
Meta.keybindings_set_custom_handler('switch-panels',
Lang.bind(this, this._startA11ySwitcher));
Main.overview.connect('showing', Lang.bind(this, function() {
for (let i = 0; i < this._dimmedWindows.length; i++)
@ -141,16 +149,6 @@ WindowManager.prototype = {
}));
},
setKeybindingHandler: function(keybinding, handler){
if (this._keyBindingHandlers[keybinding])
this._shellwm.disconnect(this._keyBindingHandlers[keybinding]);
else
this._shellwm.takeover_keybinding(keybinding);
this._keyBindingHandlers[keybinding] =
this._shellwm.connect('keybinding::' + keybinding, handler);
},
blockAnimations: function() {
this._animationBlockCount++;
},
@ -534,37 +532,41 @@ WindowManager.prototype = {
shellwm.completed_switch_workspace();
},
_startAppSwitcher : function(shellwm, binding, mask, window, backwards) {
_startAppSwitcher : function(display, screen, window, binding) {
/* prevent a corner case where both popups show up at once */
if (this._workspaceSwitcherPopup != null)
this._workspaceSwitcherPopup.actor.hide();
let tabPopup = new AltTab.AltTabPopup();
if (!tabPopup.show(backwards, binding, mask))
let modifiers = binding.get_modifiers();
let backwards = modifiers & Meta.VirtualModifier.SHIFT_MASK;
if (!tabPopup.show(backwards, binding.get_name(), binding.get_mask()))
tabPopup.destroy();
},
_startA11ySwitcher : function(shellwm, binding, mask, window, backwards) {
Main.ctrlAltTabManager.popup(backwards, mask);
_startA11ySwitcher : function(display, screen, window, binding) {
let modifiers = binding.get_modifiers();
let backwards = modifiers & Meta.VirtualModifier.SHIFT_MASK;
Main.ctrlAltTabManager.popup(backwards, binding.get_mask());
},
_showWorkspaceSwitcher : function(shellwm, binding, mask, window, backwards) {
if (global.screen.n_workspaces == 1)
_showWorkspaceSwitcher : function(display, screen, window, binding) {
if (screen.n_workspaces == 1)
return;
if (this._workspaceSwitcherPopup == null)
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
if (binding == 'switch-to-workspace-up')
if (binding.get_name() == 'switch-to-workspace-up')
this.actionMoveWorkspaceUp();
else if (binding == 'switch-to-workspace-down')
else if (binding.get_name() == 'switch-to-workspace-down')
this.actionMoveWorkspaceDown();
// left/right would effectively act as synonyms for up/down if we enabled them;
// but that could be considered confusing.
// else if (binding == 'switch-to-workspace-left')
// else if (binding.get_name() == 'switch-to-workspace-left')
// this.actionMoveWorkspaceLeft();
// else if (binding == 'switch-to-workspace-right')
// else if (binding.get_name() == 'switch-to-workspace-right')
// this.actionMoveWorkspaceRight();
},