[PATCH libinput 3/3] touchpad: don't try to position fake touches when no fingers are down

Peter Hutterer peter.hutterer at who-t.net
Wed Dec 2 13:43:29 PST 2015


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 at who-t.net>
---
 src/evdev-mt-touchpad.c |  3 ++-
 test/touchpad.c         | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 8804658..4fba147 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -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
diff --git a/test/touchpad.c b/test/touchpad.c
index 9f5e5a9..e024ace 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -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);
-- 
2.5.0



More information about the wayland-devel mailing list