[gnome-shell/wip/exalm/gestures: 1/21] js: Update gestures for updated gesture tracker



commit 59373ad9fe9f6c1c6bebb4c33e6b7c6e666baef7
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Sun Jun 16 16:28:29 2019 +0200

    js: Update gestures for updated gesture tracker
    
    With the new gesture tracker, we no longer need the grab-op-begin signal
    handlers since the gesture tracker automatically takes care of this in
    X11 sessions.
    
    Also the gesture trigger edge property has an updated name now because
    it has been moved into it's own class, so use that name.

 js/ui/edgeDragAction.js | 16 +++++-----------
 js/ui/viewSelector.js   | 10 +++-------
 js/ui/windowManager.js  | 25 +++++++------------------
 js/ui/workspacesView.js |  2 +-
 4 files changed, 16 insertions(+), 37 deletions(-)
---
diff --git a/js/ui/edgeDragAction.js b/js/ui/edgeDragAction.js
index e811dda21..bc026b4ef 100644
--- a/js/ui/edgeDragAction.js
+++ b/js/ui/edgeDragAction.js
@@ -15,8 +15,6 @@ var EdgeDragAction = GObject.registerClass({
         this._side = side;
         this._allowedModes = allowedModes;
         this.set_n_touch_points(1);
-
-        global.display.connect('grab-op-begin', () => { this.cancel(); });
     }
 
     _getMonitorRect(x, y) {
@@ -26,7 +24,7 @@ var EdgeDragAction = GObject.registerClass({
         return global.display.get_monitor_geometry(monitorIndex);
     }
 
-    vfunc_gesture_prepare(actor) {
+    vfunc_gesture_prepare(actor, point) {
         if (this.get_n_current_points() == 0)
             return false;
 
@@ -42,27 +40,23 @@ var EdgeDragAction = GObject.registerClass({
                 (this._side == St.Side.BOTTOM && y > monitorRect.y + monitorRect.height - EDGE_THRESHOLD));
     }
 
-    vfunc_gesture_progress(actor) {
+    vfunc_gesture_progress(actor, point) {
         let [startX, startY] = this.get_press_coords(0);
         let [x, y] = this.get_motion_coords(0);
         let offsetX = Math.abs (x - startX);
         let offsetY = Math.abs (y - startY);
 
         if (offsetX < EDGE_THRESHOLD && offsetY < EDGE_THRESHOLD)
-            return true;
+            return;
 
         if ((offsetX > offsetY &&
              (this._side == St.Side.TOP || this._side == St.Side.BOTTOM)) ||
             (offsetY > offsetX &&
-             (this._side == St.Side.LEFT || this._side == St.Side.RIGHT))) {
+             (this._side == St.Side.LEFT || this._side == St.Side.RIGHT)))
             this.cancel();
-            return false;
-        }
-
-        return true;
     }
 
-    vfunc_gesture_end(actor) {
+    vfunc_gesture_end(actor, point) {
         let [startX, startY] = this.get_press_coords(0);
         let [x, y] = this.get_motion_coords(0);
         let monitorRect = this._getMonitorRect(startX, startY);
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 77146552d..ba32163f0 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -68,13 +68,9 @@ var ShowOverviewAction = GObject.registerClass({
     _init() {
         super._init();
         this.set_n_touch_points(3);
-
-        global.display.connect('grab-op-begin', () => {
-            this.cancel();
-        });
     }
 
-    vfunc_gesture_prepare(actor) {
+    vfunc_gesture_prepare(actor, point) {
         return Main.actionMode == Shell.ActionMode.NORMAL &&
                this.get_n_current_points() == this.get_n_touch_points();
     }
@@ -108,12 +104,12 @@ var ShowOverviewAction = GObject.registerClass({
                                     height: maxY - minY });
     }
 
-    vfunc_gesture_begin(actor) {
+    vfunc_gesture_begin(actor, point) {
         this._initialRect = this._getBoundingRect(false);
         return true;
     }
 
-    vfunc_gesture_end(actor) {
+    vfunc_gesture_end(actor, point) {
         let rect = this._getBoundingRect(true);
         let oldArea = this._initialRect.width * this._initialRect.height;
         let newArea = rect.width * rect.height;
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 1d94e1583..763b9ee55 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -545,26 +545,21 @@ var WorkspaceSwitchAction = GObject.registerClass({
         this.set_n_touch_points(4);
         this._swept = false;
         this._allowedModes = allowedModes;
-
-        global.display.connect('grab-op-begin', () => {
-            this.cancel();
-        });
     }
 
-    vfunc_gesture_prepare(actor) {
+    vfunc_gesture_begin(actor, point) {
         this._swept = false;
 
-        if (!super.vfunc_gesture_prepare(actor))
+        if (!super.vfunc_gesture_begin(actor, point))
             return false;
 
         return (this._allowedModes & Main.actionMode);
     }
 
-    vfunc_gesture_progress(actor) {
+    vfunc_gesture_progress(actor, point) {
         let [x, y] = this.get_motion_coords(0);
         let [xPress, yPress] = this.get_press_coords(0);
         this.emit('motion', x - xPress, y - yPress);
-        return true;
     }
 
     vfunc_gesture_cancel(actor) {
@@ -603,13 +598,9 @@ var AppSwitchAction = GObject.registerClass({
     _init() {
         super._init();
         this.set_n_touch_points(3);
-
-        global.display.connect('grab-op-begin', () => {
-            this.cancel();
-        });
     }
 
-    vfunc_gesture_prepare(actor) {
+    vfunc_gesture_prepare(actor, point) {
         if (Main.actionMode != Shell.ActionMode.NORMAL) {
             this.cancel();
             return false;
@@ -618,7 +609,7 @@ var AppSwitchAction = GObject.registerClass({
         return this.get_n_current_points() <= 4;
     }
 
-    vfunc_gesture_begin(actor) {
+    vfunc_gesture_begin(actor, point) {
         // in milliseconds
         const LONG_PRESS_TIMEOUT = 250;
 
@@ -642,7 +633,7 @@ var AppSwitchAction = GObject.registerClass({
         return this.get_n_current_points() <= 4;
     }
 
-    vfunc_gesture_progress(actor) {
+    vfunc_gesture_progress(actor, point) {
         const MOTION_THRESHOLD = 30;
 
         if (this.get_n_current_points() == 3) {
@@ -652,12 +643,10 @@ var AppSwitchAction = GObject.registerClass({
 
                 if (Math.abs(x - startX) > MOTION_THRESHOLD ||
                     Math.abs(y - startY) > MOTION_THRESHOLD)
-                    return false;
+                    this.cancel();
             }
 
         }
-
-        return true;
     }
 });
 
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 78a1c8104..53dd1dce1 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -441,7 +441,7 @@ var WorkspacesDisplay = class {
         Main.overview.addAction(clickAction);
         this.actor.bind_property('mapped', clickAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
 
-        let panAction = new Clutter.PanAction({ threshold_trigger_edge: Clutter.GestureTriggerEdge.AFTER });
+        let panAction = new Clutter.PanAction({ trigger_edge: Clutter.TriggerEdge.AFTER });
         panAction.connect('pan', this._onPan.bind(this));
         panAction.connect('gesture-begin', () => {
             if (this._workspacesOnlyOnPrimary) {


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