[gnome-shell-extensions] extension: Reuse original handler in keyPressHandler injection
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] extension: Reuse original handler in keyPressHandler injection
- Date: Mon, 29 Sep 2014 13:32:20 +0000 (UTC)
commit d4ca2aeeb5303d851b810febc57474ef7977ae5b
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Sep 27 12:25:38 2014 +0200
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 files changed, 10 insertions(+), 17 deletions(-)
---
diff --git a/extensions/alternate-tab/extension.js b/extensions/alternate-tab/extension.js
index 3167b10..52d07bb 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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]