summaryrefslogtreecommitdiff
path: root/tools/shared.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-10-06 15:35:44 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2020-10-06 16:12:17 +1000
commit4f282688acdab2cd388866e4afdd9c76237f43e7 (patch)
tree342827563ca1b81fe73b0394db32fa931e0dcfca /tools/shared.c
parent7244e36b501b5c13bfed085cd57db5a3d2d0f5f3 (diff)
downloadlibinput-4f282688acdab2cd388866e4afdd9c76237f43e7.tar.gz
tools: print the libinput_dispatch() counter for debugging messages
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>
Diffstat (limited to 'tools/shared.c')
-rw-r--r--tools/shared.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/shared.c b/tools/shared.c
index a55a9157..fce32d71 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -43,6 +43,15 @@
#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)