From b3e93034498ae7eb4ca86681b6ba4e44a4a6b2c7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 8 Sep 2016 15:55:47 +1000 Subject: [PATCH] tools: prefix debug output with '-' on device changes 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 --- 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 67432b71..0e956112 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