From af86152370b9f2ff15d3adb5e0590da7fb64e7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Sch=C3=B6ller?= Date: Sat, 5 May 2018 03:49:32 +0200 Subject: [PATCH] touchpad: fix tapping that happens after a moving thumb When finger movement exceeded the motion threshold before the finger was recognized as a thumb, it would never be regarded as a thumb by the tap system. This prohibited tapping until the thumb was lifted. This is fixed by moving the check for the thumb state up such that it happens before the motion threshold check. Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-tap.c | 7 +++---- test/test-touchpad.c | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 5946dc8f..e3e051ca 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -1039,6 +1039,9 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time) tp_tap_handle_event(tp, t, TAP_EVENT_RELEASE, time); } t->tap.state = TAP_TOUCH_STATE_IDLE; + } else if (tp->tap.state != TAP_STATE_IDLE && + t->thumb.state == THUMB_STATE_YES) { + tp_tap_handle_event(tp, t, TAP_EVENT_THUMB, time); } else if (tp->tap.state != TAP_STATE_IDLE && tp_tap_exceeds_motion_threshold(tp, t)) { struct tp_touch *tmp; @@ -1051,10 +1054,6 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time) } tp_tap_handle_event(tp, t, TAP_EVENT_MOTION, time); - } else if (tp->tap.state != TAP_STATE_IDLE && - t->thumb.state == THUMB_STATE_YES && - !t->tap.is_thumb) { - tp_tap_handle_event(tp, t, TAP_EVENT_THUMB, time); } } diff --git a/test/test-touchpad.c b/test/test-touchpad.c index b73d9e58..8341e209 100644 --- a/test/test-touchpad.c +++ b/test/test-touchpad.c @@ -4974,6 +4974,45 @@ START_TEST(touchpad_thumb_tap_hold_2ndfg_tap) } END_TEST +START_TEST(touchpad_thumb_move_and_tap) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + struct axis_replacement axes[] = { + { ABS_MT_PRESSURE, 75 }, + { -1, 0 } + }; + + if (!has_thumb_detect(dev)) + return; + + litest_enable_tap(dev->libinput_device); + litest_drain_events(li); + + /* trigger thumb detection by pressure after a slight movement */ + litest_touch_down(dev, 0, 50, 99); + litest_touch_move(dev, 0, 51, 99); + litest_touch_move_extended(dev, 0, 55, 99, axes); + libinput_dispatch(li); + + litest_assert_empty_queue(li); + + /* thumb is resting, check if tapping still works */ + litest_touch_down(dev, 1, 50, 50); + litest_touch_up(dev, 1); + libinput_dispatch(li); + litest_timeout_tap(); + + 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 + START_TEST(touchpad_tool_tripletap_touch_count) { struct litest_device *dev = litest_current_device(); @@ -6081,6 +6120,7 @@ TEST_COLLECTION(touchpad) litest_add("touchpad:thumb", touchpad_thumb_tap_hold, LITEST_CLICKPAD, LITEST_ANY); litest_add("touchpad:thumb", touchpad_thumb_tap_hold_2ndfg, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH); litest_add("touchpad:thumb", touchpad_thumb_tap_hold_2ndfg_tap, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH); + litest_add("touchpad:thumb", touchpad_thumb_move_and_tap, LITEST_CLICKPAD, LITEST_ANY); litest_add_for_device("touchpad:bugs", touchpad_tool_tripletap_touch_count, LITEST_SYNAPTICS_TOPBUTTONPAD); litest_add_for_device("touchpad:bugs", touchpad_slot_swap, LITEST_SYNAPTICS_TOPBUTTONPAD);