tp_filter_motion(tp, &dx, &dy, time);
/* Require at least three px scrolling to start */
- if (dy <= -3.0 || dy >= 3.0) {
- tp->scroll.state = SCROLL_STATE_SCROLLING;
+ if (dy <= -3.0 || dy >= 3.0)
tp->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
- }
- if (dx <= -3.0 || dx >= 3.0) {
- tp->scroll.state = SCROLL_STATE_SCROLLING;
- tp->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
- }
- if (tp->scroll.state == SCROLL_STATE_NONE)
- return;
+ if (dx <= -3.0 || dx >= 3.0)
+ tp->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
/* Stop spurious MOTION events at the end of scrolling */
tp_for_each_touch(tp, t)
static void
tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time)
{
- if (tp->scroll.state == SCROLL_STATE_NONE)
- return;
-
/* terminate scrolling with a zero scroll event */
if (tp->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
pointer_notify_axis(&tp->device->base,
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
0);
- tp->scroll.state = SCROLL_STATE_NONE;
tp->scroll.direction = 0;
}
tp_init_scroll(struct tp_dispatch *tp)
{
tp->scroll.direction = 0;
- tp->scroll.state = SCROLL_STATE_NONE;
return 0;
}
END_TEST
static void
-test_2fg_scroll(struct litest_device *dev, int dx, int dy)
+test_2fg_scroll(struct litest_device *dev, int dx, int dy, int sleep)
{
+ struct libinput *li = dev->libinput;
+
litest_touch_down(dev, 0, 47, 50);
litest_touch_down(dev, 1, 53, 50);
litest_touch_move_to(dev, 0, 47, 50, 47 + dx, 50 + dy, 5);
litest_touch_move_to(dev, 1, 53, 50, 53 + dx, 50 + dy, 5);
+ /* Avoid a small scroll being seen as a tap */
+ if (sleep) {
+ libinput_dispatch(li);
+ msleep(sleep);
+ libinput_dispatch(li);
+ }
+
litest_touch_up(dev, 1);
litest_touch_up(dev, 0);
+
+ libinput_dispatch(li);
}
static void
struct libinput_event *event, *next_event;
struct libinput_event_pointer *ptrev;
- libinput_dispatch(li);
-
event = libinput_get_event(li);
next_event = libinput_get_event(li);
ck_assert(next_event != NULL); /* At least 1 scroll + stop scroll */
/* Note this mixes in a tiny amount of movement in the wrong direction,
which should be ignored */
- test_2fg_scroll(dev, 1, 40);
+ test_2fg_scroll(dev, 1, 40, 0);
check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 10);
- test_2fg_scroll(dev, 1, -40);
+ test_2fg_scroll(dev, 1, -40, 0);
check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -10);
- test_2fg_scroll(dev, 40, 1);
+ test_2fg_scroll(dev, 40, 1, 0);
check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 10);
- test_2fg_scroll(dev, -40, 1);
+ test_2fg_scroll(dev, -40, 1, 0);
check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -10);
+
+ /* 2fg scroll smaller than the threshold should not generate events */
+ test_2fg_scroll(dev, 1, 1, 200);
+ litest_assert_empty_queue(li);
}
END_TEST