[PATCH libinput 3/6] evdev: don't send frame events if we filtered the touch event

Peter Hutterer peter.hutterer at who-t.net
Mon Aug 22 06:14:55 UTC 2016


If the touch is inactive the seat_slot is -1 and we filter the event. The same
happens for devices that send may touch events but aren't touch devices like
any touch-capable mouse. In those cases we sent a bunch of 'empty' touch frame
events. Stop this by checking if we actually flushed the respective event.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c | 84 +++++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 57 insertions(+), 27 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index a7a187b..4bd4aab 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -450,7 +450,7 @@ fallback_flush_absolute_motion(struct fallback_dispatch *dispatch,
 	pointer_notify_motion_absolute(base, time, &point);
 }
 
-static void
+static bool
 fallback_flush_mt_down(struct fallback_dispatch *dispatch,
 		       struct evdev_device *device,
 		       int slot_idx,
@@ -463,7 +463,7 @@ fallback_flush_mt_down(struct fallback_dispatch *dispatch,
 	int seat_slot;
 
 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
-		return;
+		return false;
 
 	slot = &dispatch->mt.slots[slot_idx];
 	if (slot->seat_slot != -1) {
@@ -473,14 +473,14 @@ fallback_flush_mt_down(struct fallback_dispatch *dispatch,
 			       "%s: Driver sent multiple touch down for the "
 			       "same slot",
 			       udev_device_get_devnode(device->udev_device));
-		return;
+		return false;
 	}
 
 	seat_slot = ffs(~seat->slot_map) - 1;
 	slot->seat_slot = seat_slot;
 
 	if (seat_slot == -1)
-		return;
+		return false;
 
 	seat->slot_map |= 1 << seat_slot;
 	point = slot->point;
@@ -489,9 +489,11 @@ fallback_flush_mt_down(struct fallback_dispatch *dispatch,
 
 	touch_notify_touch_down(base, time, slot_idx, seat_slot,
 				&point);
+
+	return true;
 }
 
-static void
+static bool
 fallback_flush_mt_motion(struct fallback_dispatch *dispatch,
 			 struct evdev_device *device,
 			 int slot_idx,
@@ -503,24 +505,26 @@ fallback_flush_mt_motion(struct fallback_dispatch *dispatch,
 	int seat_slot;
 
 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
-		return;
+		return false;
 
 	slot = &dispatch->mt.slots[slot_idx];
 	seat_slot = slot->seat_slot;
 	point = slot->point;
 
 	if (seat_slot == -1)
-		return;
+		return false;
 
 	if (fallback_filter_defuzz_touch(dispatch, device, slot))
-		return;
+		return false;
 
 	evdev_transform_absolute(device, &point);
 	touch_notify_touch_motion(base, time, slot_idx, seat_slot,
 				  &point);
+
+	return true;
 }
 
-static void
+static bool
 fallback_flush_mt_up(struct fallback_dispatch *dispatch,
 		     struct evdev_device *device,
 		     int slot_idx,
@@ -532,21 +536,23 @@ fallback_flush_mt_up(struct fallback_dispatch *dispatch,
 	int seat_slot;
 
 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
-		return;
+		return false;
 
 	slot = &dispatch->mt.slots[slot_idx];
 	seat_slot = slot->seat_slot;
 	slot->seat_slot = -1;
 
 	if (seat_slot == -1)
-		return;
+		return false;
 
 	seat->slot_map &= ~(1 << seat_slot);
 
 	touch_notify_touch_up(base, time, slot_idx, seat_slot);
+
+	return true;
 }
 
-static void
+static bool
 fallback_flush_st_down(struct fallback_dispatch *dispatch,
 		       struct evdev_device *device,
 		       uint64_t time)
@@ -557,7 +563,7 @@ fallback_flush_st_down(struct fallback_dispatch *dispatch,
 	int seat_slot;
 
 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
-		return;
+		return false;
 
 	if (dispatch->abs.seat_slot != -1) {
 		struct libinput *libinput = evdev_libinput_context(device);
@@ -566,14 +572,14 @@ fallback_flush_st_down(struct fallback_dispatch *dispatch,
 			       "%s: Driver sent multiple touch down for the "
 			       "same slot",
 			       udev_device_get_devnode(device->udev_device));
-		return;
+		return false;
 	}
 
 	seat_slot = ffs(~seat->slot_map) - 1;
 	dispatch->abs.seat_slot = seat_slot;
 
 	if (seat_slot == -1)
-		return;
+		return false;
 
 	seat->slot_map |= 1 << seat_slot;
 
@@ -581,9 +587,11 @@ fallback_flush_st_down(struct fallback_dispatch *dispatch,
 	evdev_transform_absolute(device, &point);
 
 	touch_notify_touch_down(base, time, -1, seat_slot, &point);
+
+	return true;
 }
 
-static void
+static bool
 fallback_flush_st_motion(struct fallback_dispatch *dispatch,
 			 struct evdev_device *device,
 			 uint64_t time)
@@ -598,12 +606,14 @@ fallback_flush_st_motion(struct fallback_dispatch *dispatch,
 	seat_slot = dispatch->abs.seat_slot;
 
 	if (seat_slot == -1)
-		return;
+		return false;
 
 	touch_notify_touch_motion(base, time, -1, seat_slot, &point);
+
+	return true;
 }
 
-static void
+static bool
 fallback_flush_st_up(struct fallback_dispatch *dispatch,
 		     struct evdev_device *device,
 		     uint64_t time)
@@ -613,17 +623,19 @@ fallback_flush_st_up(struct fallback_dispatch *dispatch,
 	int seat_slot;
 
 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
-		return;
+		return false;
 
 	seat_slot = dispatch->abs.seat_slot;
 	dispatch->abs.seat_slot = -1;
 
 	if (seat_slot == -1)
-		return;
+		return false;
 
 	seat->slot_map &= ~(1 << seat_slot);
 
 	touch_notify_touch_up(base, time, -1, seat_slot);
+
+	return true;
 }
 
 static enum evdev_event_type
@@ -644,23 +656,40 @@ fallback_flush_pending_event(struct fallback_dispatch *dispatch,
 		break;
 	case EVDEV_ABSOLUTE_MT_DOWN:
 		slot_idx = dispatch->mt.slot;
-		fallback_flush_mt_down(dispatch, device, slot_idx, time);
+		if (!fallback_flush_mt_down(dispatch,
+					    device,
+					    slot_idx,
+					    time))
+			sent_event = EVDEV_NONE;
 		break;
 	case EVDEV_ABSOLUTE_MT_MOTION:
 		slot_idx = dispatch->mt.slot;
-		fallback_flush_mt_motion(dispatch, device, slot_idx, time);
+		if (!fallback_flush_mt_motion(dispatch,
+					      device,
+					      slot_idx,
+					      time))
+			sent_event = EVDEV_NONE;
 		break;
 	case EVDEV_ABSOLUTE_MT_UP:
 		slot_idx = dispatch->mt.slot;
-		fallback_flush_mt_up(dispatch, device, slot_idx, time);
+		if (!fallback_flush_mt_up(dispatch,
+					  device,
+					  slot_idx,
+					  time))
+			sent_event = EVDEV_NONE;
 		break;
 	case EVDEV_ABSOLUTE_TOUCH_DOWN:
-		fallback_flush_st_down(dispatch, device, time);
+		if (!fallback_flush_st_down(dispatch, device, time))
+			sent_event = EVDEV_NONE;
 		break;
 	case EVDEV_ABSOLUTE_MOTION:
 		if (device->seat_caps & EVDEV_DEVICE_TOUCH) {
-			fallback_flush_st_motion(dispatch, device, time);
-			sent_event = EVDEV_ABSOLUTE_MT_MOTION;
+			if (fallback_flush_st_motion(dispatch,
+						     device,
+						     time))
+				sent_event = EVDEV_ABSOLUTE_MT_MOTION;
+			else
+				sent_event = EVDEV_NONE;
 		} else if (device->seat_caps & EVDEV_DEVICE_POINTER) {
 			fallback_flush_absolute_motion(dispatch,
 						       device,
@@ -668,7 +697,8 @@ fallback_flush_pending_event(struct fallback_dispatch *dispatch,
 		}
 		break;
 	case EVDEV_ABSOLUTE_TOUCH_UP:
-		fallback_flush_st_up(dispatch, device, time);
+		if (!fallback_flush_st_up(dispatch, device, time))
+			sent_event = EVDEV_NONE;
 		break;
 	default:
 		assert(0 && "Unknown pending event type");
-- 
2.7.4



More information about the wayland-devel mailing list