{
struct evdev_device *device = data;
- device->scroll.button_scroll_state = BUTTONSCROLL_SCROLLING;
+ device->scroll.button_scroll_state = BUTTONSCROLL_READY;
}
static void
"invalid state IDLE for button up\n");
break;
case BUTTONSCROLL_BUTTON_DOWN:
+ case BUTTONSCROLL_READY:
log_debug(evdev_libinput_context(device),
"btnscroll: cancel\n");
- /* If the button is released quickly enough emit the
+
+ /* If the button is released quickly enough or
+ * without scroll events, emit the
* button press/release events. */
evdev_pointer_post_button(device,
device->scroll.button_down_time,
log_debug(evdev_libinput_context(device),
"btnscroll: discarding\n");
return true;
+ case BUTTONSCROLL_READY:
+ device->scroll.button_scroll_state = BUTTONSCROLL_SCROLLING;
+ /* fallthrough */
case BUTTONSCROLL_SCROLLING:
evdev_post_scroll(device, time,
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
enum evdev_button_scroll_state {
BUTTONSCROLL_IDLE,
BUTTONSCROLL_BUTTON_DOWN, /* button is down */
- BUTTONSCROLL_SCROLLING, /* scrolling */
+ BUTTONSCROLL_READY, /* ready for scroll events */
+ BUTTONSCROLL_SCROLLING, /* have sent scroll events */
};
struct mt_slot {
litest_button_scroll(dev, BTN_LEFT, -9, 1);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -9);
- /* scroll smaller than the threshold should not generate events */
+ /* scroll smaller than the threshold should not generate axis events */
litest_button_scroll(dev, BTN_LEFT, 1, 1);
- /* left press without movement should not generate events */
- litest_button_scroll(dev, BTN_LEFT, 0, 0);
+ litest_button_scroll(dev, BTN_LEFT, 0, 0);
+ litest_assert_button_event(li, BTN_LEFT,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ litest_assert_button_event(li,
+ BTN_LEFT,
+ LIBINPUT_BUTTON_STATE_RELEASED);
litest_assert_empty_queue(li);
/* Restore default scroll behavior */
litest_timeout_buttonscroll();
libinput_dispatch(li);
litest_button_click(device, BTN_LEFT, false);
+
+ litest_assert_button_event(li, BTN_LEFT,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ litest_assert_button_event(li,
+ BTN_LEFT,
+ LIBINPUT_BUTTON_STATE_RELEASED);
litest_assert_empty_queue(li);
}
END_TEST
litest_button_scroll(dev, BTN_MIDDLE, -9, 1);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -9);
- /* scroll smaller than the threshold should not generate events */
+ /* scroll smaller than the threshold should not generate axis events */
litest_button_scroll(dev, BTN_MIDDLE, 1, 1);
- /* long middle press without movement should not generate events */
+
litest_button_scroll(dev, BTN_MIDDLE, 0, 0);
+ litest_assert_button_event(li, BTN_MIDDLE,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ litest_assert_button_event(li,
+ BTN_MIDDLE,
+ LIBINPUT_BUTTON_STATE_RELEASED);
litest_assert_empty_queue(li);
}