[PATCH libinput] touchpad: if the second finger is within 20x5mm, bias towards 2fg scrolling

Hans de Goede hdegoede at redhat.com
Sat Feb 27 16:45:52 UTC 2016


Hi,

On 11-02-16 21:56, Peter Hutterer wrote:
> Scrolling is much more common than a 2fg spread gesture, so if the finger
> position indicates that the fingers are next to each other, switch to
> scrolling immediately.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=93504
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

Sorry for being a bit slow on reviewing this one, this
seems to be a good solution to me (I consider false positives unlikely):

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans


> ---
>   src/evdev-mt-touchpad-gestures.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
> index dc8d606..a9d7fa1 100644
> --- a/src/evdev-mt-touchpad-gestures.c
> +++ b/src/evdev-mt-touchpad-gestures.c
> @@ -325,8 +325,9 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
>   	struct tp_touch *first = tp->gesture.touches[0],
>   			*second = tp->gesture.touches[1];
>   	int dir1, dir2;
> -	int yres = tp->device->abs.absinfo_y->resolution;
> -	int vert_distance;
> +	int yres = tp->device->abs.absinfo_y->resolution,
> +	    xres = tp->device->abs.absinfo_x->resolution;
> +	int vert_distance, horiz_distance;
>
>   	/* for two-finger gestures, if the fingers stay unmoving for a
>   	 * while, assume (slow) scroll */
> @@ -338,10 +339,16 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
>
>   	/* Else check if one finger is > 20mm below the others */
>   	vert_distance = abs(first->point.y - second->point.y);
> +	horiz_distance = abs(first->point.x - second->point.x);
>   	if (vert_distance > 20 * yres &&
>   	    tp->gesture.enabled) {
>   		tp_gesture_init_pinch(tp);
>   		return GESTURE_STATE_PINCH;
> +	/* Else if the fingers are within 20x5mm of each other */
> +	} else if (vert_distance < 5 * yres &&
> +		   horiz_distance < 20 * xres) {
> +		tp_gesture_set_scroll_buildup(tp);
> +		return GESTURE_STATE_SCROLL;
>   	}
>
>   	/* Else wait for both fingers to have moved */
>


More information about the wayland-devel mailing list