[PATCH libinput] tools: prefix debug output with '.' on device changes

Peter Hutterer peter.hutterer at who-t.net
Thu Sep 8 05:55:47 UTC 2016


We print the sysname, but it's not always obvious when there's an event from
another device within the stream from another device. Prefix it so it's easier
to spot and search for.

See https://bugzilla.redhat.com/show_bug.cgi?id=1364850#c3 for an example of
how such an event can hide.

We only use last_device for comparing pointer values so we don't need a
reference to the device, it doesn't matter if the device itself goes out of
scope.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 tools/event-debug.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/event-debug.c b/tools/event-debug.c
index 67432b7..0e95611 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -49,8 +49,11 @@ static unsigned int stop = 0;
 static void
 print_event_header(struct libinput_event *ev)
 {
+	/* use for pointer value only, do not dereference */
+	static struct libinput_device *last_device = NULL;
 	struct libinput_device *dev = libinput_event_get_device(ev);
 	const char *type = NULL;
+	char prefix;
 
 	switch(libinput_event_get_type(ev)) {
 	case LIBINPUT_EVENT_NONE:
@@ -132,7 +135,14 @@ print_event_header(struct libinput_event *ev)
 		break;
 	}
 
-	printf("%-7s	%-16s ", libinput_device_get_sysname(dev), type);
+	prefix = (last_device != dev) ? '-' : ' ';
+
+	printf("%c%-7s	%-16s ",
+	       prefix,
+	       libinput_device_get_sysname(dev),
+	       type);
+
+	last_device = dev;
 }
 
 static void
-- 
2.7.4



More information about the wayland-devel mailing list