[PATCH 2/2] input: Warn if the touch point up and down events get out of sync

Neil Roberts neil at linux.intel.com
Tue Sep 24 07:53:06 PDT 2013


The weston_seat struct now keeps a bit mask of the touch points that
are pressed so that it can give a warning if it gets a down event for
a finger that is already down or an up event for one that is already
up.
---

I was using this patch to test bug 67563 but I think it could be a
good idea to land so that we'll catch similar bugs in future.

 src/compositor.h |  3 +++
 src/input.c      | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/src/compositor.h b/src/compositor.h
index a19d966..117406b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -478,6 +478,9 @@ struct weston_seat {
 	struct wl_signal selection_signal;
 
 	uint32_t num_tp;
+	/* This is just used to generate a warning if the touch
+	 * up/down events get out of sync */
+	uint32_t tp_mask;
 
 	void (*led_update)(struct weston_seat *ws, enum weston_led leds);
 
diff --git a/src/input.c b/src/input.c
index 0c3e480..b040e22 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1102,6 +1102,14 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
 
 		seat->num_tp++;
 
+		if (touch_id < (int) sizeof(seat->tp_mask) * 8) {
+			if ((seat->tp_mask & (1 << touch_id)))
+				weston_log("touch down received for %i "
+					   "but it is already down\n",
+					   touch_id);
+			seat->tp_mask |= 1 << touch_id;
+		}
+
 		/* the first finger down picks the surface, and all further go
 		 * to that surface for the remainder of the touch session i.e.
 		 * until all touch points are up again. */
@@ -1142,6 +1150,14 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
 		weston_compositor_idle_release(ec);
 		seat->num_tp--;
 
+		if (touch_id < (int) sizeof(seat->tp_mask) * 8) {
+			if (!(seat->tp_mask & (1 << touch_id)))
+				weston_log("touch up received for %i "
+					   "but it isn't down\n",
+					   touch_id);
+			seat->tp_mask &= ~(1 << touch_id);
+		}
+
 		grab->interface->up(grab, time, touch_id);
 		if (seat->num_tp == 0)
 			weston_touch_set_focus(seat, NULL);
-- 
1.8.3.1



More information about the wayland-devel mailing list