Semi-MT devices provide a bounding box of the fingers, and internally we don't
treat them as real MT device. Depending which finger currently provides
ABS_X/Y we may get a large jump when the other finger is released.
Basic sequence is finger 1 down, finger 2 down, finger 1 up.
On the last interaction, the ABS_X/Y which was on finger 1's coordinates now
jumps to finger 2's coordinates. This is interpreted as movement by the
tapping code, resulting in missed two-finger taps.

Ignore these movements on semi-mt devices.

https://bugs.freedesktop.org/show_bug.cgi?id=105043

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 src/evdev-mt-touchpad-tap.c |  7 +++++++
 test/test-touchpad-tap.c    | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index ad0a6512..5946dc8f 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -942,6 +942,13 @@ tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp,
                return false;
        }
 
+       /* Semi-mt devices will give us large movements on finger release,
+        * depending which touch is released. Make sure we ignore any
+        * movement in the same frame as a finger change.
+        */
+       if (tp->semi_mt && tp->nfingers_down != tp->old_nfingers_down)
+               return false;
+
        return length_in_mm(mm) > DEFAULT_TAP_MOVE_THRESHOLD;
 }
 
diff --git a/test/test-touchpad-tap.c b/test/test-touchpad-tap.c
index 2e1c556d..5dfca28b 100644
--- a/test/test-touchpad-tap.c
+++ b/test/test-touchpad-tap.c
@@ -1073,6 +1073,37 @@ START_TEST(touchpad_2fg_tap_inverted)
 }
 END_TEST
 
+START_TEST(touchpad_2fg_tap_move_on_release)
+{
+       struct litest_device *dev = litest_current_device();
+       struct libinput *li = dev->libinput;
+
+       litest_enable_tap(dev->libinput_device);
+       litest_drain_events(dev->libinput);
+
+       litest_touch_down(dev, 0, 50, 50);
+       litest_touch_down(dev, 1, 70, 70);
+
+       litest_push_event_frame(dev);
+       litest_touch_move(dev, 0, 55, 55);
+       litest_touch_up(dev, 1);
+       litest_pop_event_frame(dev);
+
+       litest_touch_up(dev, 0);
+
+       libinput_dispatch(li);
+
+       litest_assert_button_event(li,
+                                  BTN_RIGHT,
+                                  LIBINPUT_BUTTON_STATE_PRESSED);
+       litest_assert_button_event(li,
+                                  BTN_RIGHT,
+                                  LIBINPUT_BUTTON_STATE_RELEASED);
+
+       litest_assert_empty_queue(li);
+}
+END_TEST
+
 START_TEST(touchpad_2fg_tap_n_hold_first)
 {
        struct litest_device *dev = litest_current_device();
@@ -3408,6 +3439,7 @@ litest_setup_tests_touchpad_tap(void)
        litest_add("tap-2fg:2fg", touchpad_2fg_tap_n_drag_3fg, LITEST_TOUCHPAD, 
LITEST_SINGLE_TOUCH);
        litest_add_ranged("tap-2fg:2fg", touchpad_2fg_tap, LITEST_TOUCHPAD, 
LITEST_SINGLE_TOUCH|LITEST_SEMI_MT, &tap_map_range);
        litest_add_ranged("tap-2fg:2fg", touchpad_2fg_tap_inverted, 
LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &tap_map_range);
+       litest_add("tap-2fg:2fg", touchpad_2fg_tap_move_on_release, 
LITEST_TOUCHPAD|LITEST_SEMI_MT, LITEST_SINGLE_TOUCH);
        litest_add("tap-2fg:2fg", touchpad_2fg_tap_n_hold_first, 
LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
        litest_add("tap-2fg:2fg", touchpad_2fg_tap_n_hold_second, 
LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
        litest_add("tap-2fg:2fg", touchpad_2fg_tap_quickrelease, 
LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT);
-- 
2.14.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to