code = evdev_to_left_handed(device, code);
- evdev_pointer_notify_physical_button(device, time, code, state);
+ fallback_notify_physical_button(fallback, device, time, code, state);
}
static void
}
}
+void
+fallback_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)
+ dispatch->wheel.is_inhibited = (state == LIBINPUT_BUTTON_STATE_PRESSED);
+
+ evdev_pointer_notify_physical_button(device, time, button, state);
+}
+
static enum libinput_switch_state
fallback_interface_get_switch_state(struct evdev_dispatch *evdev_dispatch,
enum libinput_switch sw)
if (!(device->seat_caps & EVDEV_DEVICE_POINTER))
return;
+ if (dispatch->wheel.is_inhibited) {
+ dispatch->wheel.delta.x = 0;
+ dispatch->wheel.delta.y = 0;
+ return;
+ }
+
if (device->model_flags & EVDEV_MODEL_LENOVO_SCROLLPOINT) {
struct normalized_coords unaccel = { 0.0, 0.0 };
struct {
struct device_coords delta;
+ bool is_inhibited;
} wheel;
struct {
void fallback_init_debounce(struct fallback_dispatch *dispatch);
void fallback_debounce_handle_state(struct fallback_dispatch *dispatch,
uint64_t time);
+void
+fallback_notify_physical_button(struct fallback_dispatch *dispatch,
+ struct evdev_device *device,
+ uint64_t time,
+ int button,
+ enum libinput_button_state state);
#endif
}
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_natural_defaults)
{
struct litest_device *dev = litest_current_device();
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(pointer_scroll_button, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
litest_add(pointer_scroll_button_noscroll, LITEST_ABSOLUTE|LITEST_BUTTON, LITEST_RELATIVE);
litest_add(pointer_scroll_button_noscroll, LITEST_ANY, LITEST_RELATIVE|LITEST_BUTTON);