touchpad: don't try to position fake touches when no fingers are down
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 2 Dec 2015 00:36:30 +0000 (10:36 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 2 Dec 2015 21:35:09 +0000 (07:35 +1000)
If all fingers are released in the same frame, we won't be able to find the
top-most touch.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev-mt-touchpad.c
test/touchpad.c

index 8804658de6bb505bb729c4afc249abb47449c952..4fba147d62bd80afe027317f5ce045f06b564201 100644 (file)
@@ -832,7 +832,8 @@ tp_position_fake_touches(struct tp_dispatch *tp)
        struct tp_touch *topmost = NULL;
        unsigned int start, i;
 
-       if (tp_fake_finger_count(tp) <= tp->num_slots)
+       if (tp_fake_finger_count(tp) <= tp->num_slots ||
+           tp->nfingers_down == 0)
                return;
 
        /* We have at least one fake touch down. Find the top-most real
index 9f5e5a95a21ba0c8d2e0b1cc95d3d55406d9f06b..e024ace60c8357cbcd7528496a4df2842ec4bc61 100644 (file)
@@ -1703,6 +1703,31 @@ START_TEST(touchpad_semi_mt_hover_2fg_1fg_down)
 }
 END_TEST
 
+START_TEST(touchpad_semi_mt_hover_2fg_up)
+{
+       struct litest_device *dev = litest_current_device();
+       struct libinput *li = dev->libinput;
+
+       litest_touch_down(dev, 0, 70, 50);
+       litest_touch_down(dev, 1, 50, 50);
+
+       litest_push_event_frame(dev);
+       litest_touch_move(dev, 0, 72, 50);
+       litest_touch_move(dev, 1, 52, 50);
+       litest_event(dev, EV_KEY, BTN_TOUCH, 0);
+       litest_pop_event_frame(dev);
+
+       litest_event(dev, EV_ABS, ABS_MT_SLOT, 0);
+       litest_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
+       litest_event(dev, EV_ABS, ABS_MT_SLOT, 1);
+       litest_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
+       litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
+       litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+       litest_drain_events(li);
+}
+END_TEST
+
 START_TEST(touchpad_hover_noevent)
 {
        struct litest_device *dev = litest_current_device();
@@ -3521,6 +3546,7 @@ litest_setup_tests(void)
        litest_add_for_device("touchpad:semi-mt-hover", touchpad_semi_mt_hover_down_hover_down, LITEST_SYNAPTICS_HOVER_SEMI_MT);
        litest_add_for_device("touchpad:semi-mt-hover", touchpad_semi_mt_hover_2fg_noevent, LITEST_SYNAPTICS_HOVER_SEMI_MT);
        litest_add_for_device("touchpad:semi-mt-hover", touchpad_semi_mt_hover_2fg_1fg_down, LITEST_SYNAPTICS_HOVER_SEMI_MT);
+       litest_add_for_device("touchpad:semi-mt-hover", touchpad_semi_mt_hover_2fg_up, LITEST_SYNAPTICS_HOVER_SEMI_MT);
 
        litest_add("touchpad:hover", touchpad_hover_noevent, LITEST_TOUCHPAD|LITEST_HOVER, LITEST_ANY);
        litest_add("touchpad:hover", touchpad_hover_down, LITEST_TOUCHPAD|LITEST_HOVER, LITEST_ANY);