fallback: don't send a single-touch motion if we just sent a begin
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 16 Oct 2019 02:50:44 +0000 (12:50 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 16 Oct 2019 03:43:45 +0000 (03:43 +0000)
Any touch down event will also provide motion data, but we must not send a
motion event for those in the same frame as the down event.

Fixes #375

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-fallback.c
test/test-touch.c

index 05d92cfc0b0b0bcca8ab0aeee6fffc88a31a8f74..1a9113bc7bcbacd435efa3df99a78250f9c9e212 100644 (file)
@@ -977,9 +977,7 @@ fallback_handle_state(struct fallback_dispatch *dispatch,
        if (dispatch->pending_event & EVDEV_ABSOLUTE_TOUCH_DOWN) {
                if (fallback_flush_st_down(dispatch, device, time))
                        need_touch_frame = true;
-       }
-
-       if (dispatch->pending_event & EVDEV_ABSOLUTE_MOTION) {
+       } else if (dispatch->pending_event & EVDEV_ABSOLUTE_MOTION) {
                if (device->seat_caps & EVDEV_DEVICE_TOUCH) {
                        if (fallback_flush_st_motion(dispatch,
                                                     device,
index fc2f50c459d770d8192ad3a0fe0794ef791593c1..81accf9476262a1f818bbec5789bae86d15291f1 100644 (file)
@@ -64,6 +64,25 @@ START_TEST(touch_frame_events)
 }
 END_TEST
 
+START_TEST(touch_downup_no_motion)
+{
+       struct litest_device *dev = litest_current_device();
+       struct libinput *li = dev->libinput;
+
+       litest_drain_events(li);
+
+       litest_touch_down(dev, 0, 10, 10);
+       libinput_dispatch(li);
+
+       litest_assert_touch_down_frame(li);
+
+       litest_touch_up(dev, 0);
+       libinput_dispatch(li);
+
+       litest_assert_touch_up_frame(li);
+}
+END_TEST
+
 START_TEST(touch_abs_transform)
 {
        struct litest_device *dev;
@@ -1322,6 +1341,8 @@ TEST_COLLECTION(touch)
        struct range axes = { ABS_X, ABS_Y + 1};
 
        litest_add("touch:frame", touch_frame_events, LITEST_TOUCH, LITEST_ANY);
+       litest_add("touch:down", touch_downup_no_motion, LITEST_TOUCH, LITEST_ANY);
+       litest_add("touch:down", touch_downup_no_motion, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
        litest_add_no_device("touch:abs-transform", touch_abs_transform);
        litest_add("touch:slots", touch_seat_slot, LITEST_TOUCH, LITEST_TOUCHPAD);
        litest_add_no_device("touch:slots", touch_many_slots);