mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 13:30:27 +01:00
wheel: allow to scroll while middle button is pressed
Since cd4f2f32b5 ("fallback: disable mouse scroll wheel while middle
button is pressed") the mouse wheel is inhibited while the mouse wheel
is pressed.
The original intention of this feature was to avoid unintended scroll
while pressing the scroll wheel. However, now that high-resolution
scroll is fully integrated in libinput we can improve this feature and
filter unintended scroll (below half a detent) and allow it when it is
intended (over half a detent).
Remove the "WHEEL_STATE_PRESSED" state from the wheel state machine and
let the general heuristics handle this case.
Also, remove the specific tests for this feature as now it is covered
by the general test cases.
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
This commit is contained in:
parent
cddf956990
commit
cf6c97119f
4 changed files with 0 additions and 131 deletions
|
|
@ -68,8 +68,6 @@ fallback_notify_physical_button(struct fallback_dispatch *dispatch,
|
|||
int button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
fallback_wheel_notify_physical_button(dispatch, device, time,
|
||||
button, state);
|
||||
evdev_pointer_notify_physical_button(device, time, button, state);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ enum palm_state {
|
|||
|
||||
enum wheel_state {
|
||||
WHEEL_STATE_NONE,
|
||||
WHEEL_STATE_PRESSED,
|
||||
WHEEL_STATE_ACCUMULATING_SCROLL,
|
||||
WHEEL_STATE_SCROLLING,
|
||||
};
|
||||
|
|
@ -280,13 +279,6 @@ void
|
|||
fallback_init_wheel(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device);
|
||||
|
||||
void
|
||||
fallback_wheel_notify_physical_button(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int button,
|
||||
enum libinput_button_state state);
|
||||
|
||||
void
|
||||
fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@
|
|||
#define WHEEL_SCROLL_TIMEOUT ms2us(500)
|
||||
|
||||
enum wheel_event {
|
||||
WHEEL_EVENT_PRESS,
|
||||
WHEEL_EVENT_RELEASE,
|
||||
WHEEL_EVENT_SCROLL_ACCUMULATED,
|
||||
WHEEL_EVENT_SCROLL,
|
||||
WHEEL_EVENT_SCROLL_TIMEOUT,
|
||||
|
|
@ -47,7 +45,6 @@ wheel_state_to_str(enum wheel_state state)
|
|||
{
|
||||
switch(state) {
|
||||
CASE_RETURN_STRING(WHEEL_STATE_NONE);
|
||||
CASE_RETURN_STRING(WHEEL_STATE_PRESSED);
|
||||
CASE_RETURN_STRING(WHEEL_STATE_ACCUMULATING_SCROLL);
|
||||
CASE_RETURN_STRING(WHEEL_STATE_SCROLLING);
|
||||
}
|
||||
|
|
@ -58,8 +55,6 @@ static inline const char*
|
|||
wheel_event_to_str(enum wheel_event event)
|
||||
{
|
||||
switch(event) {
|
||||
CASE_RETURN_STRING(WHEEL_EVENT_PRESS);
|
||||
CASE_RETURN_STRING(WHEEL_EVENT_RELEASE);
|
||||
CASE_RETURN_STRING(WHEEL_EVENT_SCROLL_ACCUMULATED);
|
||||
CASE_RETURN_STRING(WHEEL_EVENT_SCROLL);
|
||||
CASE_RETURN_STRING(WHEEL_EVENT_SCROLL_TIMEOUT);
|
||||
|
|
@ -96,36 +91,11 @@ wheel_handle_event_on_state_none(struct fallback_dispatch *dispatch,
|
|||
uint64_t time)
|
||||
{
|
||||
switch (event) {
|
||||
case WHEEL_EVENT_PRESS:
|
||||
dispatch->wheel.state = WHEEL_STATE_PRESSED;
|
||||
break;
|
||||
case WHEEL_EVENT_SCROLL:
|
||||
dispatch->wheel.state = WHEEL_STATE_ACCUMULATING_SCROLL;
|
||||
break;
|
||||
case WHEEL_EVENT_SCROLL_DIR_CHANGED:
|
||||
break;
|
||||
case WHEEL_EVENT_RELEASE:
|
||||
case WHEEL_EVENT_SCROLL_ACCUMULATED:
|
||||
case WHEEL_EVENT_SCROLL_TIMEOUT:
|
||||
log_wheel_bug(dispatch, event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
wheel_handle_event_on_state_pressed(struct fallback_dispatch *dispatch,
|
||||
enum wheel_event event,
|
||||
uint64_t time)
|
||||
{
|
||||
switch (event) {
|
||||
case WHEEL_EVENT_RELEASE:
|
||||
dispatch->wheel.state = WHEEL_STATE_NONE;
|
||||
break;
|
||||
case WHEEL_EVENT_SCROLL:
|
||||
case WHEEL_EVENT_SCROLL_DIR_CHANGED:
|
||||
/* Ignore scroll while the wheel is pressed */
|
||||
break;
|
||||
case WHEEL_EVENT_PRESS:
|
||||
case WHEEL_EVENT_SCROLL_ACCUMULATED:
|
||||
case WHEEL_EVENT_SCROLL_TIMEOUT:
|
||||
log_wheel_bug(dispatch, event);
|
||||
|
|
@ -139,9 +109,6 @@ wheel_handle_event_on_state_accumulating_scroll(struct fallback_dispatch *dispat
|
|||
uint64_t time)
|
||||
{
|
||||
switch (event) {
|
||||
case WHEEL_EVENT_PRESS:
|
||||
dispatch->wheel.state = WHEEL_STATE_PRESSED;
|
||||
break;
|
||||
case WHEEL_EVENT_SCROLL_ACCUMULATED:
|
||||
dispatch->wheel.state = WHEEL_STATE_SCROLLING;
|
||||
wheel_set_scroll_timer(dispatch, time);
|
||||
|
|
@ -152,7 +119,6 @@ wheel_handle_event_on_state_accumulating_scroll(struct fallback_dispatch *dispat
|
|||
case WHEEL_EVENT_SCROLL_DIR_CHANGED:
|
||||
dispatch->wheel.state = WHEEL_STATE_NONE;
|
||||
break;
|
||||
case WHEEL_EVENT_RELEASE:
|
||||
case WHEEL_EVENT_SCROLL_TIMEOUT:
|
||||
log_wheel_bug(dispatch, event);
|
||||
break;
|
||||
|
|
@ -165,10 +131,6 @@ wheel_handle_event_on_state_scrolling(struct fallback_dispatch *dispatch,
|
|||
uint64_t time)
|
||||
{
|
||||
switch (event) {
|
||||
case WHEEL_EVENT_PRESS:
|
||||
dispatch->wheel.state = WHEEL_STATE_PRESSED;
|
||||
wheel_cancel_scroll_timer(dispatch);
|
||||
break;
|
||||
case WHEEL_EVENT_SCROLL:
|
||||
wheel_cancel_scroll_timer(dispatch);
|
||||
wheel_set_scroll_timer(dispatch, time);
|
||||
|
|
@ -180,7 +142,6 @@ wheel_handle_event_on_state_scrolling(struct fallback_dispatch *dispatch,
|
|||
wheel_cancel_scroll_timer(dispatch);
|
||||
dispatch->wheel.state = WHEEL_STATE_NONE;
|
||||
break;
|
||||
case WHEEL_EVENT_RELEASE:
|
||||
case WHEEL_EVENT_SCROLL_ACCUMULATED:
|
||||
log_wheel_bug(dispatch, event);
|
||||
break;
|
||||
|
|
@ -198,9 +159,6 @@ wheel_handle_event(struct fallback_dispatch *dispatch,
|
|||
case WHEEL_STATE_NONE:
|
||||
wheel_handle_event_on_state_none(dispatch, event, time);
|
||||
break;
|
||||
case WHEEL_STATE_PRESSED:
|
||||
wheel_handle_event_on_state_pressed(dispatch, event, time);
|
||||
break;
|
||||
case WHEEL_STATE_ACCUMULATING_SCROLL:
|
||||
wheel_handle_event_on_state_accumulating_scroll(dispatch,
|
||||
event,
|
||||
|
|
@ -309,17 +267,6 @@ wheel_handle_state_none(struct fallback_dispatch *dispatch,
|
|||
|
||||
}
|
||||
|
||||
static void
|
||||
wheel_handle_state_pressed(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time)
|
||||
{
|
||||
dispatch->wheel.hi_res.x = 0;
|
||||
dispatch->wheel.hi_res.y = 0;
|
||||
dispatch->wheel.lo_res.x = 0;
|
||||
dispatch->wheel.lo_res.y = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
wheel_handle_state_accumulating_scroll(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
|
|
@ -403,21 +350,6 @@ fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
fallback_wheel_notify_physical_button(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
if (button == BTN_MIDDLE) {
|
||||
if (state == LIBINPUT_BUTTON_STATE_PRESSED)
|
||||
wheel_handle_event(dispatch, WHEEL_EVENT_PRESS, time);
|
||||
else
|
||||
wheel_handle_event(dispatch, WHEEL_EVENT_RELEASE, time);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fallback_wheel_handle_state(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
|
|
@ -442,9 +374,6 @@ fallback_wheel_handle_state(struct fallback_dispatch *dispatch,
|
|||
case WHEEL_STATE_NONE:
|
||||
wheel_handle_state_none(dispatch, device, time);
|
||||
break;
|
||||
case WHEEL_STATE_PRESSED:
|
||||
wheel_handle_state_pressed(dispatch, device, time);
|
||||
break;
|
||||
case WHEEL_STATE_ACCUMULATING_SCROLL:
|
||||
wheel_handle_state_accumulating_scroll(dispatch, device, time);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -701,54 +701,6 @@ START_TEST(pointer_scroll_wheel)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(pointer_scroll_wheel_pressed_noscroll)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_button_click_debounced(dev, li, BTN_MIDDLE, true);
|
||||
litest_drain_events(li);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
litest_event(dev, EV_REL, REL_WHEEL, 1);
|
||||
litest_event(dev, EV_REL, REL_HWHEEL, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
}
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_button_click_debounced(dev, li, BTN_MIDDLE, false);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(pointer_scroll_hi_res_wheel_pressed_noscroll)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_button_click_debounced(dev, li, BTN_MIDDLE, true);
|
||||
litest_drain_events(li);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 12);
|
||||
litest_event(dev, EV_REL, REL_HWHEEL_HI_RES, 12);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
}
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_button_click_debounced(dev, li, BTN_MIDDLE, false);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
test_hi_res_wheel_event(struct litest_device *dev, int which, int v120_amount)
|
||||
{
|
||||
|
|
@ -3575,8 +3527,6 @@ TEST_COLLECTION(pointer)
|
|||
litest_add_for_device(pointer_button_has_no_button, LITEST_KEYBOARD);
|
||||
litest_add(pointer_recover_from_lost_button_count, LITEST_BUTTON, LITEST_CLICKPAD);
|
||||
litest_add(pointer_scroll_wheel, LITEST_WHEEL, LITEST_TABLET);
|
||||
litest_add_for_device(pointer_scroll_wheel_pressed_noscroll, LITEST_MOUSE);
|
||||
litest_add_for_device(pointer_scroll_hi_res_wheel_pressed_noscroll, LITEST_MOUSE);
|
||||
litest_add(pointer_scroll_wheel_hires, LITEST_WHEEL, LITEST_TABLET);
|
||||
litest_add(pointer_scroll_wheel_hires_send_only_lores_vertical, LITEST_WHEEL, LITEST_TABLET);
|
||||
litest_add(pointer_scroll_wheel_hires_send_only_lores_horizontal, LITEST_WHEEL, LITEST_TABLET);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue