tools: print the libinput_dispatch() counter for debugging messages
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 6 Oct 2020 05:35:44 +0000 (15:35 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 6 Oct 2020 06:12:17 +0000 (16:12 +1000)
The messages with priority DEBUG refer to the various internal state machines
updating, so it's useful to know when they did so. Let's count up every time
we trigger libinput_dispatch() so we know how the messages group together.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/libinput-debug-events.c
tools/libinput-debug-gui.c
tools/shared.c
tools/shared.h

index 433bfc87b25d22e881eda8ef498527e815900e3a..42125dc0880ce511986ad92cb0c845df69fd89e0 100644 (file)
@@ -824,7 +824,7 @@ handle_and_print_events(struct libinput *li)
        int rc = -1;
        struct libinput_event *ev;
 
-       libinput_dispatch(li);
+       tools_dispatch(li);
        while ((ev = libinput_get_event(li))) {
                print_event_header(ev);
 
index 70e41e16748c63c15af0b04909210d51fbf47644..64af64493437d96244a0ac14971341483ba97fb6 100644 (file)
@@ -1422,7 +1422,7 @@ handle_event_libinput(GIOChannel *source, GIOCondition condition, gpointer data)
        struct window *w = libinput_get_user_data(li);
        struct libinput_event *ev;
 
-       libinput_dispatch(li);
+       tools_dispatch(li);
 
        while ((ev = libinput_get_event(li))) {
                switch (libinput_event_get_type(ev)) {
index a55a91579e0ffbc72adb92d22c7fb63618259441..fce32d711d750e014dcbc97e15e18fdef4d77388 100644 (file)
 #include "util-macros.h"
 #include "util-strings.h"
 
+static uint32_t dispatch_counter = 0;
+
+void
+tools_dispatch(struct libinput *libinput)
+{
+       dispatch_counter++;
+       libinput_dispatch(libinput);
+}
+
 LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
 static void
 log_handler(struct libinput *li,
@@ -51,6 +60,7 @@ log_handler(struct libinput *li,
            va_list args)
 {
        static int is_tty = -1;
+       static uint32_t last_dispatch_no = 0;
 
        if (is_tty == -1)
                is_tty = isatty(STDOUT_FILENO);
@@ -62,6 +72,14 @@ log_handler(struct libinput *li,
                        printf(ANSI_HIGHLIGHT);
        }
 
+       if (priority < LIBINPUT_LOG_PRIORITY_INFO) {
+               if (dispatch_counter != last_dispatch_no) {
+                       last_dispatch_no = dispatch_counter;
+                       printf("%4u: ", dispatch_counter);
+               } else {
+                       printf(" %4s ", "...");
+               }
+       }
        vprintf(format, args);
 
        if (is_tty && priority >= LIBINPUT_LOG_PRIORITY_INFO)
index 730e1a45690d269418a85d480728cedcbfe6d82e..471c39956c0db8cc3cf4a1697529eb2751b693b7 100644 (file)
@@ -132,4 +132,6 @@ tools_list_device_quirks(struct quirks_context *ctx,
                         void (*callback)(void *userdata, const char *str),
                         void *userdata);
 
+void
+tools_dispatch(struct libinput *libinput);
 #endif