From d4ca2aeeb5303d851b810febc57474ef7977ae5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 27 Sep 2014 12:25:38 +0200 Subject: [PATCH] extension: Reuse original handler in keyPressHandler injection We do need to inject our own handler to treat application-switch actions the same way as the corresponding window-switch ones; we can actually express exactly this without re-implementing the entire function, by calling the original handler with a tweaked action parameter - the resulting code is not only more concise, but should also be a bit more robust against changes in core. https://bugzilla.gnome.org/show_bug.cgi?id=737457 --- extensions/alternate-tab/extension.js | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/extensions/alternate-tab/extension.js b/extensions/alternate-tab/extension.js index 3167b102..52d07bbd 100644 --- a/extensions/alternate-tab/extension.js +++ b/extensions/alternate-tab/extension.js @@ -20,24 +20,17 @@ function setKeybinding(name, func) { function enable() { injections['_keyPressHandler'] = AltTab.WindowSwitcherPopup.prototype._keyPressHandler; AltTab.WindowSwitcherPopup.prototype._keyPressHandler = function(keysym, action) { - if (action == Meta.KeyBindingAction.SWITCH_WINDOWS || - action == Meta.KeyBindingAction.SWITCH_APPLICATIONS || - action == Meta.KeyBindingAction.SWITCH_GROUP) { - this._select(this._next()); - } else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD || - action == Meta.KeyBindingAction.SWITCH_APPLICATIONS_BACKWARD || - action == Meta.KeyBindingAction.SWITCH_GROUP_BACKWARD) { - this._select(this._previous()); - } else { - if (keysym == Clutter.Left) - this._select(this._previous()); - else if (keysym == Clutter.Right) - this._select(this._next()); - else - return Clutter.EVENT_PROPAGATE; + switch(action) { + case Meta.KeyBindingAction.SWITCH_APPLICATIONS: + case Meta.KeyBindingAction.SWITCH_GROUP: + action = Meta.KeyBindingAction.SWITCH_WINDOWS; + break; + case Meta.KeyBindingAction.SWITCH_APPLICATIONS_BACKWARD: + case Meta.KeyBindingAction.SWITCH_GROUP_BACKWARD: + action = Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD; + break; } - - return Clutter.EVENT_STOP; + return injections['_keyPressHandler'].call(this, keysym, action); }; setKeybinding('switch-applications', Lang.bind(Main.wm, Main.wm._startWindowSwitcher));