[PATCH libinput] gestures: make the gesture movement threshold depending on finger count
Eric Engestrom
eric.engestrom at imgtec.com
Thu Jun 30 13:10:24 UTC 2016
On Thu, Jun 30, 2016 at 12:22:10PM +1000, Peter Hutterer wrote:
> Increase the mm move threshold for 3 and 4 finger gestures to 2 and 3 mm,
> respectively. In multi-finger gestures it's common to have minor movement
> while all fingers are being put down or before the conscious movement starts.
> This can trigger invalid gesture detection (e.g. a pinch instead of a swipe).
> Increase the movement threshold to make sure we have sufficient input data.
>
> No changes to 2-finger movements.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=96687
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> src/evdev-mt-touchpad-gestures.c | 9 ++++++---
> test/gestures.c | 10 +++++-----
> 2 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
> index e4e465a..a910bec 100644
> --- a/src/evdev-mt-touchpad-gestures.c
> +++ b/src/evdev-mt-touchpad-gestures.c
> @@ -182,12 +182,15 @@ tp_gesture_get_active_touches(const struct tp_dispatch *tp,
> }
>
> static int
> -tp_gesture_get_direction(struct tp_dispatch *tp, struct tp_touch *touch)
> +tp_gesture_get_direction(struct tp_dispatch *tp, struct tp_touch *touch,
> + unsigned int nfingers)
> {
> struct normalized_coords normalized;
> struct device_float_coords delta;
> double move_threshold = TP_MM_TO_DPI_NORMALIZED(1);
>
> + move_threshold *= (nfingers - 1);
The threshold now becomes 0 for 1 finger, which I assume was not the
intended behaviour. Should `-1` be removed (and the commit message adapted)?
Alternatively, something like this would give the result from the commit
message:
move_threshold *= min(1, nfingers - 1);
> +
> delta = device_delta(touch->point, touch->gesture.initial);
>
> normalized = tp_normalize_delta(tp, delta);
> @@ -347,8 +350,8 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
> }
>
> /* Else wait for both fingers to have moved */
> - dir1 = tp_gesture_get_direction(tp, first);
> - dir2 = tp_gesture_get_direction(tp, second);
> + dir1 = tp_gesture_get_direction(tp, first, tp->gesture.finger_count);
> + dir2 = tp_gesture_get_direction(tp, second, tp->gesture.finger_count);
> if (dir1 == UNDEFINED_DIRECTION || dir2 == UNDEFINED_DIRECTION)
> return GESTURE_STATE_UNKNOWN;
>
[...]
More information about the wayland-devel
mailing list