[gnome-shell-extensions] windowNavigator: fix workspace switching



commit fa4ac23a4d64d37fbaade5d0b3281a88bb50b1e7
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Aug 1 17:25:24 2011 +0200

    windowNavigator: fix workspace switching
    
    Apparently, clutter_event_get_key_unicode() is not reliable for
    numeric keys, and fails above 2. Let's use clutter_event_get_key_symbol()
    and fix it.

 extensions/windowsNavigator/extension.js |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/extensions/windowsNavigator/extension.js b/extensions/windowsNavigator/extension.js
index 3dbc52e..017be96 100644
--- a/extensions/windowsNavigator/extension.js
+++ b/extensions/windowsNavigator/extension.js
@@ -96,13 +96,13 @@ function main() {
     }
 
     WorkspacesView.WorkspacesView.prototype._onKeyRelease = function(s, o) {
-        if (this._pickWindow && o.get_key_symbol() == Clutter.Alt_L)
+        if (this._pickWindow && o.get_key_symbol() == Clutter.KEY_Alt_L)
             this._hideTooltips();
-        if (this._pickWorkspace && o.get_key_symbol() == Clutter.Control_L)
+        if (this._pickWorkspace && o.get_key_symbol() == Clutter.KEY_Control_L)
             this._hideWorkspacesTooltips();
     }
     WorkspacesView.WorkspacesView.prototype._onKeyPress = function(s, o) {
-        if (o.get_key_symbol() == Clutter.Alt_L && !this._pickWorkspace) {
+        if (o.get_key_symbol() == Clutter.KEY_Alt_L && !this._pickWorkspace) {
             this._prevFocusActor = global.stage.get_key_focus();
             global.stage.set_key_focus(null);
             this._active = global.screen.get_active_workspace_index();
@@ -110,7 +110,7 @@ function main() {
             this._workspaces[global.screen.get_active_workspace_index()].showWindowsTooltips();
             return true;
         }
-        if (o.get_key_symbol() == Clutter.Control_L && !this._pickWindow) {
+        if (o.get_key_symbol() == Clutter.KEY_Control_L && !this._pickWindow) {
             this._prevFocusActor = global.stage.get_key_focus();
             global.stage.set_key_focus(null);
             this._pickWorkspace = true;
@@ -127,26 +127,32 @@ function main() {
                 this._hideTooltips();
                 return false;
             }
-            let c = o.get_key_unicode();
-            if (c > '9'.charCodeAt(0) || c < '0'.charCodeAt(0)) {
+
+            let c = o.get_key_symbol() - Clutter.KEY_0;
+            if (c > 9 || c <= 0) {
                 this._hideTooltips();
                 return false;
             }
-            let win = this._workspaces[this._active].getWindowWithTooltip(c - '0'.charCodeAt(0));
+
+            let win = this._workspaces[this._active].getWindowWithTooltip(c);
             this._hideTooltips();
+
             if (win)
                 Main.activateWindow(win, global.get_current_time());
+
             return true;
         }
         if (this._pickWorkspace) {
-            let c = o.get_key_unicode();
-            if (c > '9'.charCodeAt(0) || c < '0'.charCodeAt(0)) {
+            let c = o.get_key_symbol() - Clutter.KEY_0;
+            if (c > 9 || c <= 0) {
                 this._hideWorkspacesTooltips();
                 return false;
             }
-            let workspace = this._workspaces[c - '0'.charCodeAt(0) - 1];
+
+            let workspace = this._workspaces[c - 1];
             if (workspace !== undefined)
                 workspace.metaWorkspace.activate(global.get_current_time());
+
             this._hideWorkspacesTooltips();
             return true;
         }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]