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



commit 4e67c6eba78e2c1c3377c717219754f6cd56cd8b
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.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/596

 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 7ba22fdfc..00c96a2e0 100644
--- a/js/ui/edgeDragAction.js
+++ b/js/ui/edgeDragAction.js
@@ -16,8 +16,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) {
@@ -27,7 +25,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;
 
@@ -43,27 +41,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 b43544ea1..ec91e88cb 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -69,13 +69,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();
     }
@@ -109,12 +105,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 c732a62d9..e3d16cc85 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 7a7f9666e..0d2bd40d6 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -473,7 +473,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]