diff --git a/js/ui/main.js b/js/ui/main.js index 6849292e0..c160fee0d 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -132,15 +132,11 @@ function _initUserSession() { ExtensionSystem.init(); ExtensionSystem.loadExtensions(); - let shellwm = global.window_manager; - - shellwm.takeover_keybinding('panel-run-dialog'); - shellwm.connect('keybinding::panel-run-dialog', function () { + Meta.keybindings_set_custom_handler('panel-run-dialog', function() { getRunDialog().open(); }); - shellwm.takeover_keybinding('panel-main-menu'); - shellwm.connect('keybinding::panel-main-menu', function () { + Meta.keybindings_set_custom_handler('panel-main-menu', function () { overview.toggle(); }); diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index b9b4181df..4343a2012 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -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(); }, diff --git a/src/shell-wm.c b/src/shell-wm.c index dbc47aba3..bfa972882 100644 --- a/src/shell-wm.c +++ b/src/shell-wm.c @@ -28,8 +28,6 @@ enum KILL_SWITCH_WORKSPACE, KILL_WINDOW_EFFECTS, - KEYBINDING, - LAST_SIGNAL }; @@ -126,34 +124,6 @@ shell_wm_class_init (ShellWMClass *klass) g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, META_TYPE_WINDOW_ACTOR); - - /** - * ShellWM::keybinding: - * @shellwm: the #ShellWM - * @binding: the keybinding name - * @mask: the modifier mask used - * @window: for window keybindings, the #MetaWindow - * @backwards: for "reversible" keybindings, whether or not - * the backwards (Shifted) variant was invoked - * - * Emitted when a keybinding captured via - * shell_wm_takeover_keybinding() is invoked. The keybinding name - * (which has underscores, not hyphens) is also included as the - * detail of the signal name, so you can connect just specific - * keybindings. - */ - shell_wm_signals[KEYBINDING] = - g_signal_new ("keybinding", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - _shell_marshal_VOID__STRING_UINT_OBJECT_BOOLEAN, - G_TYPE_NONE, 4, - G_TYPE_STRING, - G_TYPE_UINT, - META_TYPE_WINDOW, - G_TYPE_BOOLEAN); } void @@ -324,37 +294,3 @@ shell_wm_new (MetaPlugin *plugin) return wm; } - -static void -shell_wm_key_handler (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding, - gpointer data) -{ - ShellWM *wm = data; - gboolean backwards = (event->xkey.state & ShiftMask); - - g_signal_emit (wm, shell_wm_signals[KEYBINDING], - g_quark_from_string (binding->name), - binding->name, binding->mask, window, backwards); -} - -/** - * shell_wm_takeover_keybinding: - * @wm: the #ShellWM - * @binding_name: a meta keybinding name - * - * Tells mutter to forward keypresses for @binding_name to the shell - * rather than processing them internally. This will cause a - * #ShellWM::keybinding signal to be emitted when that key is pressed. - */ -void -shell_wm_takeover_keybinding (ShellWM *wm, - const char *binding_name) -{ - meta_keybindings_set_custom_handler (binding_name, - shell_wm_key_handler, - wm, NULL); -} diff --git a/src/shell-wm.h b/src/shell-wm.h index 81fe83f13..20b740a3b 100644 --- a/src/shell-wm.h +++ b/src/shell-wm.h @@ -39,10 +39,6 @@ void shell_wm_completed_destroy (ShellWM *wm, MetaWindowActor *actor); void shell_wm_completed_switch_workspace (ShellWM *wm); -/* Keybinding stuff */ -void shell_wm_takeover_keybinding (ShellWM *wm, - const char *binding_name); - G_END_DECLS #endif /* __SHELL_WM_H__ */