File 0001-swipeTracker-make-the-number-of-fingers-for-touchpad.patch of Package gnome-shell
From 065e6e35e679785ef6816d75b9159f9d6e49a44e Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
Date: Tue, 20 Apr 2021 16:49:39 -0400
Subject: [PATCH] swipeTracker: make the number of fingers for touchpad
gestures configurable
---
js/ui/swipeTracker.js | 55 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 40 insertions(+), 15 deletions(-)
--- a/js/ui/swipeTracker.js
+++ b/js/ui/swipeTracker.js
@@ -34,8 +34,6 @@ const DURATION_MULTIPLIER = 3;
const ANIMATION_BASE_VELOCITY = 0.002;
const EPSILON = 0.005;
-const GESTURE_FINGER_COUNT = 3;
-
/** @enum {number} */
const State = {
NONE: 0,
@@ -126,7 +124,8 @@ const TouchpadSwipeGesture = GObject.reg
if (event.get_gesture_phase() === Clutter.TouchpadGesturePhase.BEGIN)
this._state = TouchpadState.NONE;
- if (event.get_touchpad_gesture_finger_count() !== GESTURE_FINGER_COUNT)
+ let numFingers = this._touchpadSettings.get_uint('touchpad-gesture-num-fingers');
+ if (event.get_touchpad_gesture_finger_count() !== numFingers)
return Clutter.EVENT_PROPAGATE;
if ((this._allowedModes & Main.actionMode) === 0)
@@ -469,6 +468,10 @@ export const SwipeTracker = GObject.regi
this._history = new EventHistory();
this._reset();
+ this._touchpadSettings = new Gio.Settings({
+ schema_id: 'org.gnome.desktop.peripherals.touchpad',
+ });
+
this._touchpadGesture = new TouchpadSwipeGesture(allowedModes);
this._touchpadGesture.connect('begin', this._beginGesture.bind(this));
this._touchpadGesture.connect('update', this._updateGesture.bind(this));
@@ -477,18 +480,9 @@ export const SwipeTracker = GObject.regi
this.bind_property('orientation', this._touchpadGesture, 'orientation',
GObject.BindingFlags.SYNC_CREATE);
- this._touchGesture = new TouchSwipeGesture(allowedModes,
- GESTURE_FINGER_COUNT,
- Clutter.GestureTriggerEdge.AFTER);
- this._touchGesture.connect('begin', this._beginTouchSwipe.bind(this));
- this._touchGesture.connect('update', this._updateGesture.bind(this));
- this._touchGesture.connect('end', this._endTouchGesture.bind(this));
- this._touchGesture.connect('cancel', this._cancelTouchGesture.bind(this));
- this.bind_property('enabled', this._touchGesture, 'enabled', 0);
- this.bind_property('orientation', this._touchGesture, 'orientation',
- GObject.BindingFlags.SYNC_CREATE);
- this.bind_property('distance', this._touchGesture, 'distance', 0);
- global.stage.add_action_full('swipe', Clutter.EventPhase.CAPTURE, this._touchGesture);
+ let numFingers = this._touchpadSettings.get_uint('touchpad-gesture-num-fingers');
+ this._setupTouchSwipe(numFingers);
+ this._changedID = this._touchpadSettings.connect('changed', this._changed.bind(this));
if (params.allowDrag) {
this._dragGesture = new TouchSwipeGesture(allowedModes, 1,
@@ -521,6 +515,34 @@ export const SwipeTracker = GObject.regi
}
}
+ _setupTouchSwipe(numFingers) {
+ this._touchGesture = new TouchSwipeGesture(this._allowedModes, numFingers,
+ Clutter.GestureTriggerEdge.AFTER);
+ this._touchGesture.connect('begin', this._beginTouchSwipe.bind(this));
+ this._touchGesture.connect('update', this._updateGesture.bind(this));
+ this._touchGesture.connect('end', this._endTouchGesture.bind(this));
+ this._touchGesture.connect('cancel', this._cancelTouchGesture.bind(this));
+ this.bind_property('enabled', this._touchGesture, 'enabled', 0);
+ this.bind_property('orientation', this._touchGesture, 'orientation',
+ GObject.BindingFlags.SYNC_CREATE);
+ this.bind_property('distance', this._touchGesture, 'distance', 0);
+ global.stage.add_action_full('swipe', Clutter.EventPhase.CAPTURE, this._touchGesture);
+
+ this._numFingers = numFingers;
+ }
+
+ _changed() {
+ let numFingers = this._touchpadSettings.get_uint('touchpad-gesture-num-fingers');
+ if (numFingers != this._numFingers) {
+ if (this._touchGesture) {
+ global.stage.remove_action(this._touchGesture);
+ delete this._touchGesture;
+ }
+
+ this._setupTouchSwipe(numFingers);
+ }
+ }
+
/**
* canHandleScrollEvent:
* This function can be used to combine swipe gesture and mouse
@@ -770,6 +792,9 @@ export const SwipeTracker = GObject.regi
}
destroy() {
+ if (this._changedID)
+ this._touchpadSettings.disconnect(this._changedID);
+
if (this._touchpadGesture) {
this._touchpadGesture.destroy();
delete this._touchpadGesture;