[PATCH libinput 2/4] evdev: check the button scrolling state instead of the hw button state

Hans de Goede hdegoede at redhat.com
Mon Apr 11 07:45:13 UTC 2016


Hi,

On 11-04-16 05:54, Peter Hutterer wrote:
> The state of button scrolling should determine whether we filter the event,
> not the hardware button state.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>   src/evdev.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/src/evdev.c b/src/evdev.c
> index 9be4a96..e272f4b 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -273,13 +273,12 @@ evdev_post_trackpoint_scroll(struct evdev_device *device,
>   			     uint64_t time)
>   {
>   	if (device->scroll.method != LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN ||
> -	    !hw_is_key_down(device, device->scroll.button))
> +	    !device->scroll.button_scroll_active)
>   		return false;
>
> -	if (device->scroll.button_scroll_active)
> -		evdev_post_scroll(device, time,
> -				  LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
> -				  &unaccel);
> +	evdev_post_scroll(device, time,
> +			  LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
> +			  &unaccel);
>
>   	return true;
>   }
>

This won't work. I used hw_is_key_down here deliberately. The problem with
using button_scroll_active is that it does not become true immediately after
the scroll button goes down, it only becomes true after
DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT.

The purpose of the check this commit changes is to ignore pointer motion
events in the time between the button click and the timeout, rather then
sending either pointer-motion events (undesirable if the user intends to
scroll) or scroll events (undesirable if the user does not intend to
scroll).

With this patch you end up sending unwanted motion events during the
timeout when the user intends to scroll.

If you want to make this work with an emulated middle button, you are
going to need a scroll.button_pressed, set that when you start the timer,
clear it in the appropriate places and use that here instead of the
hw_is_key_down (or something similar).

Regards,

Hans


More information about the wayland-devel mailing list