From 34bab6e15efc0d7544a004cc26481850763414c2 Mon Sep 17 00:00:00 2001 From: Eduardo de Souza Cruz Date: Sun, 10 Oct 2021 23:32:36 +0000 Subject: [PATCH] evdev: disable button scroll timeout for extra mouse buttons Signed-off-by: Eduardo Cruz --- src/evdev.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index d2ce863..7ab998b 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -230,26 +230,35 @@ evdev_button_scroll_button(struct evdev_device *device, } if (is_press) { - enum timer_flags flags = TIMER_FLAG_NONE; - - device->scroll.button_scroll_state = BUTTONSCROLL_BUTTON_DOWN; + if (device->scroll.button < BTN_FORWARD) { + /* For mouse buttons 1-5 (0x110 to 0x114) we apply a timeout before scrolling + * since the button could also be used for regular clicking. */ + enum timer_flags flags = TIMER_FLAG_NONE; + + device->scroll.button_scroll_state = BUTTONSCROLL_BUTTON_DOWN; + + /* Special case: if middle button emulation is enabled and + * our scroll button is the left or right button, we only + * get here *after* the middle button timeout has expired + * for that button press. The time passed is the button-down + * time though (which is in the past), so we have to allow + * for a negative timer to be set. + */ + if (device->middlebutton.enabled && + (device->scroll.button == BTN_LEFT || + device->scroll.button == BTN_RIGHT)) { + flags = TIMER_FLAG_ALLOW_NEGATIVE; + } - /* Special case: if middle button emulation is enabled and - * our scroll button is the left or right button, we only - * get here *after* the middle button timeout has expired - * for that button press. The time passed is the button-down - * time though (which is in the past), so we have to allow - * for a negative timer to be set. - */ - if (device->middlebutton.enabled && - (device->scroll.button == BTN_LEFT || - device->scroll.button == BTN_RIGHT)) { - flags = TIMER_FLAG_ALLOW_NEGATIVE; + libinput_timer_set_flags(&device->scroll.timer, + time + DEFAULT_BUTTON_SCROLL_TIMEOUT, + flags); + } else { + /* For extra mouse buttons numbered 6 or more (0x115+) we assume it is + * dedicated exclusively to scrolling, so we don't apply the timeout + * in order to provide immediate scrolling responsiveness. */ + device->scroll.button_scroll_state = BUTTONSCROLL_READY; } - - libinput_timer_set_flags(&device->scroll.timer, - time + DEFAULT_BUTTON_SCROLL_TIMEOUT, - flags); device->scroll.button_down_time = time; evdev_log_debug(device, "btnscroll: down\n"); } else { -- 2.7.4