[gnome-shell/gnome-3-14] gestures: Restrict actions based on keybindingMode



commit 7e7eab2bea668d23b53819c79ebc761d1ea20405
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Nov 27 20:46:50 2014 +0100

    gestures: Restrict actions based on keybindingMode
    
    Just like keybindings and the message tray pointer barrier, gestures
    don't always make sense - for instance, swiping up the screen shield
    should not trigger the message tray just as the SelectArea action around
    the left edge should not open the overview.
    To avoid this, restrict gestures based on the current keybinding mode.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740237

 js/ui/edgeDragAction.js |    8 +++++++-
 js/ui/messageTray.js    |    4 +++-
 js/ui/viewSelector.js   |    6 ++++--
 js/ui/windowManager.js  |    6 ++++--
 4 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/edgeDragAction.js b/js/ui/edgeDragAction.js
index 692da41..46e96d7 100644
--- a/js/ui/edgeDragAction.js
+++ b/js/ui/edgeDragAction.js
@@ -6,6 +6,8 @@ const Meta = imports.gi.Meta;
 const Clutter = imports.gi.Clutter;
 const St = imports.gi.St;
 
+const Main = imports.ui.main;
+
 const EDGE_THRESHOLD = 20;
 const DRAG_DISTANCE = 80;
 
@@ -13,9 +15,10 @@ const EdgeDragAction = new Lang.Class({
     Name: 'EdgeDragAction',
     Extends: Clutter.GestureAction,
 
-    _init : function(side) {
+    _init : function(side, allowedModes) {
         this.parent();
         this._side = side;
+        this._allowedModes = allowedModes;
         this.set_n_touch_points(1);
 
         global.display.connect('grab-op-begin', Lang.bind(this, function() {
@@ -34,6 +37,9 @@ const EdgeDragAction = new Lang.Class({
         if (this.get_n_current_points() == 0)
             return false;
 
+        if (!(this._allowedModes & Main.keybindingMode))
+            return false;
+
         let [x, y] = this.get_press_coords(0);
         let monitorRect = this._getMonitorRect(x, y);
 
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index ad7c5c8..a034fc3 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1951,7 +1951,9 @@ const MessageTray = new Lang.Class({
         this._messageTrayMenuButton.actor.connect('key-press-event',
                                                   Lang.bind(this, this._onTrayButtonKeyPress));
 
-        let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM);
+        let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM,
+                                                        Shell.KeyBindingMode.NORMAL |
+                                                        Shell.KeyBindingMode.OVERVIEW);
         gesture.connect('activated', Lang.bind(this, this.toggle));
         global.stage.add_action(gesture);
     },
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index d0e8140..57395e3 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -65,7 +65,8 @@ const ShowOverviewAction = new Lang.Class({
     },
 
     vfunc_gesture_prepare : function(action, actor) {
-        return this.get_n_current_points() == this.get_n_touch_points();
+        return Main.keybindingMode == Shell.KeyBindingMode.NORMAL &&
+               this.get_n_current_points() == this.get_n_touch_points();
     },
 
     _getBoundingRect : function(motion) {
@@ -215,7 +216,8 @@ const ViewSelector = new Lang.Class({
 
         let gesture;
 
-        gesture = new EdgeDragAction.EdgeDragAction(St.Side.LEFT);
+        gesture = new EdgeDragAction.EdgeDragAction(St.Side.LEFT,
+                                                    Shell.KeyBindingMode.NORMAL);
         gesture.connect('activated', Lang.bind(this, function() {
             if (Main.overview.visible)
                 Main.overview.hide();
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 60ab30f..e332552 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -478,7 +478,9 @@ const WorkspaceSwitchAction = new Lang.Class({
     },
 
     vfunc_gesture_prepare : function(action, actor) {
-        return this.get_n_current_points() == this.get_n_touch_points();
+        let allowedModes = Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.OVERVIEW;
+        return this.get_n_current_points() == this.get_n_touch_points() &&
+               (allowedModes & Main.keybindingMode);
     },
 
     vfunc_gesture_end : function(action, actor) {
@@ -526,7 +528,7 @@ const AppSwitchAction = new Lang.Class({
     },
 
     vfunc_gesture_prepare : function(action, actor) {
-        if (Main.overview.visible) {
+        if (Main.keybindingMode != Shell.KeyBindingMode.NORMAL) {
             this.cancel();
             return false;
         }


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