[gnome-shell] swipeTracker: Reject touchpad swipes in the wrong directions
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] swipeTracker: Reject touchpad swipes in the wrong directions
- Date: Wed, 17 Feb 2021 13:23:04 +0000 (UTC)
commit e135f077fb3b716ef34e219b388d0911b0a7e5f3
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Jun 10 01:45:08 2020 +0200
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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1643>
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 7bd4a96bd7..5bc2c49e48 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() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]