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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2016-09-08 15:55:47 +10:00
parent 1497606912
commit b3e9303449

View file

@ -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