[PATCH libinput 2/8] evdev: Avoid double touch down/up events

Jonas Ådahl jadahl at gmail.com
Tue Mar 25 13:45:53 PDT 2014


When the kernel sends multiple touch down or touch up for the same slot
in a row, ignore any such subsequent event ensuring libinput always
produces 1 x touch down -> [n x touch motion] -> 1 x touch up event
series.

Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
 src/evdev.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/evdev.c b/src/evdev.c
index ff8b27a..729e1f4 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -135,6 +135,9 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
 		if (slot >= MAX_SLOTS)
 			break;
 
+		if (device->mt.slots[slot].seat_slot != -1)
+			break;
+
 		seat_slot = ffs(~seat->slot_map) - 1;
 		device->mt.slots[slot].seat_slot = seat_slot;
 
@@ -171,6 +174,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
 			break;
 
 		seat_slot = device->mt.slots[slot].seat_slot;
+		device->mt.slots[slot].seat_slot = -1;
 
 		if (seat_slot == -1)
 			break;
@@ -183,6 +187,9 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
 		if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
 			break;
 
+		if (device->abs.seat_slot != -1)
+			break;
+
 		seat_slot = ffs(~seat->slot_map) - 1;
 		device->abs.seat_slot = seat_slot;
 
@@ -218,6 +225,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
 			break;
 
 		seat_slot = device->abs.seat_slot;
+		device->abs.seat_slot = -1;
 
 		if (seat_slot == -1)
 			break;
@@ -655,6 +663,7 @@ evdev_device_create(struct libinput_seat *seat,
 	int rc;
 	int fd;
 	int unhandled_device = 0;
+	int i;
 
 	/* Use non-blocking mode so that we can loop on read on
 	 * evdev_device_data() until all events on the fd are
@@ -712,6 +721,10 @@ evdev_device_create(struct libinput_seat *seat,
 	if (!device->source)
 		goto err;
 
+	device->abs.seat_slot = -1;
+	for (i = 0; i < MAX_SLOTS; ++i)
+		device->mt.slots[i].seat_slot = -1;
+
 	list_insert(seat->devices_list.prev, &device->base.link);
 	notify_added_device(&device->base);
 
-- 
1.8.3.2



More information about the wayland-devel mailing list