[gnome-shell] swipeTracker: Reject touch swipes in the wrong directions



commit ea881ed0777578f58d163f9ade25d18a40e8c563
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Feb 3 16:54:25 2021 +0100

    swipeTracker: Reject touch swipes in the wrong directions
    
    We now have multiple touch swipe gestures with matching fingers and
    different directions set on the overview hierarchy. Accepting all
    touch swipes without checking the direction makes one of these gestures
    take control of input, without other gestures having a say on this.
    
    So, look for the direction of the touch events and look if it matches
    the expected orientation before accepting the gesture.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1643>

 js/ui/swipeTracker.js | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js
index cf5e01d716..1bd8a69c9d 100644
--- a/js/ui/swipeTracker.js
+++ b/js/ui/swipeTracker.js
@@ -247,6 +247,12 @@ const TouchSwipeGesture = GObject.registerClass({
         let time = this.get_last_event(0).get_time();
         let [xPress, yPress] = this.get_press_coords(0);
         let [x, y] = this.get_motion_coords(0);
+        const [xDelta, yDelta] = [x - xPress, y - yPress];
+        const swipeOrientation = Math.abs(xDelta) > Math.abs(yDelta)
+            ? Clutter.Orientation.HORIZONTAL : Clutter.Orientation.VERTICAL;
+
+        if (swipeOrientation !== this.orientation)
+            return false;
 
         this._lastPosition =
             this.orientation === Clutter.Orientation.VERTICAL ? y : x;


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