[PATCH libinput 3/6] touchpad: make gestures optional

Peter Hutterer peter.hutterer at who-t.net
Thu Jul 30 16:25:09 PDT 2015


On Thu, Jul 30, 2015 at 02:29:18PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 30-07-15 08:11, Peter Hutterer wrote:
> >Not all multi-finger touchpads are able to reliably produce gestures, so make
> >it optional. This patch just adds a boolean (currently always true) that gets
> >set on touchpad init time, i.e. it is not run-time configurable.
> >
> >Three and four-finger gestures are filtered out in gesture_notify(), if the
> >cap isn't set the event is discarded.
> >
> >For two-finger gestures we prevent a transition to PINCH, so we don't
> >inadvertently detect a pinch gesture and then not send events. This way, a 2fg
> >gesture is always scroll.
> 
> Shouldn't we just always treat 2 fingers down as scroll then ? I think that
> one of the main reasons to disable gestures would be pinch mis-detection
> when users really want to scroll, and doing things this way disabling
> gestures will not help this case.

I thought about that when doing the patch but decided for this approach on
purpose.  currently, a mis-detection of a pinch gesture with gestures
enabled means the gesture remains until the fingers are lifted. with this
patch otoh it just doesn't do anything until we detect a scroll gesture, at
which point we switch to scrolling.

the point here is that the scroll detection code is still at work, so
hopefully that "trains" users to perform the right scroll action. we get
consistent behaviour across touchpads too this way, and we avoid the
situations down the track of "it used to scroll this way but now it doesn't
anymore" when we add other features, or when we manage do to gestures
reliably on those touchpads after all.

I might be overthinking this though :)

Cheers,
   Peter

> >
> >Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> >---
> >  src/evdev-mt-touchpad-gestures.c | 5 ++++-
> >  src/evdev-mt-touchpad.c          | 3 ++-
> >  src/evdev-mt-touchpad.h          | 1 +
> >  3 files changed, 7 insertions(+), 2 deletions(-)
> >
> >diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
> >index 3b1839e..da03c26 100644
> >--- a/src/evdev-mt-touchpad-gestures.c
> >+++ b/src/evdev-mt-touchpad-gestures.c
> >@@ -295,7 +295,7 @@ tp_gesture_twofinger_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
> >  	    ((dir2 & 0x80) && (dir1 & 0x01))) {
> >  		tp_gesture_set_scroll_buildup(tp);
> >  		return GESTURE_2FG_STATE_SCROLL;
> >-	} else {
> >+	} else if (tp->gesture.enabled) {
> >  		tp_gesture_get_pinch_info(tp,
> >  					  &tp->gesture.initial_distance,
> >  					  &tp->gesture.angle,
> >@@ -303,6 +303,8 @@ tp_gesture_twofinger_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
> >  		tp->gesture.prev_scale = 1.0;
> >  		return GESTURE_2FG_STATE_PINCH;
> >  	}
> >+
> >+	return GESTURE_2FG_STATE_UNKNOWN;
> >  }
> >
> >  static enum tp_gesture_2fg_state
> >@@ -563,6 +565,7 @@ tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time)
> >  int
> >  tp_init_gesture(struct tp_dispatch *tp)
> >  {
> >+	tp->gesture.enabled = true;
> >  	tp->gesture.twofinger_state = GESTURE_2FG_STATE_NONE;
> >
> >  	libinput_timer_init(&tp->gesture.finger_count_switch_timer,
> >diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> >index e110b9a..af1cd47 100644
> >--- a/src/evdev-mt-touchpad.c
> >+++ b/src/evdev-mt-touchpad.c
> >@@ -1918,7 +1918,8 @@ tp_init(struct tp_dispatch *tp,
> >  		return -1;
> >
> >  	device->seat_caps |= EVDEV_DEVICE_POINTER;
> >-	device->seat_caps |= EVDEV_DEVICE_GESTURE;
> >+	if (tp->gesture.enabled)
> >+		device->seat_caps |= EVDEV_DEVICE_GESTURE;
> >
> >  	return 0;
> >  }
> >diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
> >index a7961e7..3bd8425 100644
> >--- a/src/evdev-mt-touchpad.h
> >+++ b/src/evdev-mt-touchpad.h
> >@@ -246,6 +246,7 @@ struct tp_dispatch {
> >  	} accel;
> >
> >  	struct {
> >+		bool enabled;
> >  		bool started;
> >  		unsigned int finger_count;
> >  		unsigned int finger_count_pending;
> >


More information about the wayland-devel mailing list