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>
This commit is contained in:
Carlos Garnacho 2021-02-03 16:54:25 +01:00
parent 504ca7d4c3
commit ea881ed077

View File

@ -247,6 +247,12 @@ const TouchSwipeGesture = GObject.registerClass({
let time = this.get_last_event(0).get_time(); let time = this.get_last_event(0).get_time();
let [xPress, yPress] = this.get_press_coords(0); let [xPress, yPress] = this.get_press_coords(0);
let [x, y] = this.get_motion_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._lastPosition =
this.orientation === Clutter.Orientation.VERTICAL ? y : x; this.orientation === Clutter.Orientation.VERTICAL ? y : x;