From e135f077fb3b716ef34e219b388d0911b0a7e5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 10 Jun 2020 01:45:08 +0200 Subject: [PATCH] swipeTracker: Reject touchpad 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 touchpad 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 swipe events and look if it matches the expected orientation. Part-of: --- js/ui/swipeTracker.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js index 7bd4a96bd..5bc2c49e4 100644 --- a/js/ui/swipeTracker.js +++ b/js/ui/swipeTracker.js @@ -124,6 +124,17 @@ const TouchpadSwipeGesture = GObject.registerClass({ let [x, y] = event.get_coords(); let [dx, dy] = event.get_gesture_motion_delta(); + let gestureOrientation = -1; + if (dx !== dy) { + gestureOrientation = Math.abs(dx) > Math.abs(dy) + ? Clutter.Orientation.HORIZONTAL + : Clutter.Orientation.VERTICAL; + } + + if (gestureOrientation >= 0 && + gestureOrientation !== this.orientation) + return Clutter.EVENT_PROPAGATE; + const vertical = this.orientation === Clutter.Orientation.VERTICAL; let delta = (vertical ? dy : dx) * SWIPE_MULTIPLIER; const distance = vertical ? TOUCHPAD_BASE_HEIGHT : TOUCHPAD_BASE_WIDTH; @@ -146,7 +157,9 @@ const TouchpadSwipeGesture = GObject.registerClass({ break; } - return Clutter.EVENT_STOP; + return gestureOrientation === this.orientation + ? Clutter.EVENT_STOP + : Clutter.EVENT_PROPAGATE; } destroy() {