Commit 12dc64af authored by Peter Hutterer's avatar Peter Hutterer

touchpad: handle a touch ending and restarting in the same frame

If a touch ends and starts again in the same frame, our touch count gets out
of whack. This later triggers an assertion when the tap touch count mismatches
the real tap count.

E: 0.105005 0003 0039 -001      # EV_ABS / ABS_MT_TRACKING_ID   -1
E: 0.105005 0003 0035 8447      # EV_ABS / ABS_MT_POSITION_X    8447
E: 0.105005 0003 0036 4479      # EV_ABS / ABS_MT_POSITION_Y    4479
E: 0.105005 0001 014a 0000      # EV_KEY / BTN_TOUCH            0
E: 0.105005 0001 0145 0000      # EV_KEY / BTN_TOOL_FINGER      0
E: 0.105005 0003 0039 0074      # EV_ABS / ABS_MT_TRACKING_ID   74
E: 0.105005 0003 0035 8388      # EV_ABS / ABS_MT_POSITION_X    8388
E: 0.105005 0003 0036 4480      # EV_ABS / ABS_MT_POSITION_Y    4480
E: 0.105005 0001 014a 0001      # EV_KEY / BTN_TOUCH            1
E: 0.105005 0001 0145 0001      # EV_KEY / BTN_TOOL_FINGER      1
E: 0.105005 0003 0000 8388      # EV_ABS / ABS_X                8388
E: 0.105005 0003 0001 4480      # EV_ABS / ABS_Y                4480
E: 0.105005 0000 0000 0000      # ------------ SYN_REPORT (0) ---------- +19ms

This is a kernel bug but let's paper over here because otherwise we crash and
that's considered impolite.

Fixes #161
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 782bbdb2
Pipeline #5739 passed with stages
in 7 minutes and 30 seconds
......@@ -305,6 +305,18 @@ tp_new_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
t->state == TOUCH_HOVERING)
return;
/* Bug #161: touch ends in the same event frame where it restarts
again. That's a kernel bug, so let's complain. */
if (t->state == TOUCH_MAYBE_END) {
evdev_log_bug_kernel(tp->device,
"touch %d ended and began in in same frame.\n",
t->index);
tp->nfingers_down++;
t->state = TOUCH_UPDATE;
t->has_ended = false;
return;
}
/* we begin the touch as hovering because until BTN_TOUCH happens we
* don't know if it's a touch down or not. And BTN_TOUCH may happen
* after ABS_MT_TRACKING_ID */
......
......@@ -6732,6 +6732,40 @@ out:
}
END_TEST
START_TEST(touchpad_end_start_touch)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
litest_enable_tap(dev->libinput_device);
litest_drain_events(li);
litest_touch_down(dev, 0, 50, 50);
litest_touch_move(dev, 0, 50.1, 50.1);
libinput_dispatch(li);
litest_push_event_frame(dev);
litest_touch_up(dev, 0);
litest_touch_down(dev, 0, 50.2, 50.2);
litest_pop_event_frame(dev);
litest_disable_log_handler(li);
libinput_dispatch(li);
litest_restore_log_handler(li);
litest_assert_empty_queue(li);
litest_timeout_tap();
libinput_dispatch(li);
litest_touch_move_to(dev, 0, 50.2, 50.2, 50, 70, 10);
litest_touch_up(dev, 0);
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
}
END_TEST
TEST_COLLECTION(touchpad)
{
struct range suspends = { SUSPEND_EXT_MOUSE, SUSPEND_COUNT };
......@@ -6928,4 +6962,8 @@ TEST_COLLECTION(touchpad)
litest_add_ranged("touchpad:suspend", touchpad_suspend_abba, LITEST_TOUCHPAD, LITEST_ANY, &suspends);
litest_add_ranged("touchpad:suspend", touchpad_suspend_abab, LITEST_TOUCHPAD, LITEST_ANY, &suspends);
/* Happens on the "Wacom Intuos Pro M Finger" but our test device
* has the same properties */
litest_add_for_device("touchpad:bugs", touchpad_end_start_touch, LITEST_WACOM_FINGER);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment