From 6c3c2e99c0db0fbec110174952ac3da192d7cb53 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 10 Mar 2025 16:11:28 +1000 Subject: [PATCH] libinput: use the shared event printing for debugging events Part-of: --- meson.build | 1 + src/libinput.c | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index 4a63a925..2869aa1e 100644 --- a/meson.build +++ b/meson.build @@ -375,6 +375,7 @@ src_libinput = src_libfilter + [ 'src/path-seat.c', 'src/udev-seat.c', 'src/timer.c', + 'src/util-libinput.c', ] deps_libinput = [ diff --git a/src/libinput.c b/src/libinput.c index 6efa896f..f6b0b4cc 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -37,6 +37,7 @@ #include "libinput.h" #include "libinput-private.h" #include "util-input-event.h" +#include "util-libinput.h" #include "evdev.h" #include "timer.h" #include "quirks.h" @@ -3172,6 +3173,16 @@ switch_notify_toggle(struct libinput_device *device, #endif } +LIBINPUT_UNUSED +static inline void +libinput_print_queued_event(struct libinput_event *event) +{ + struct libinput *libinput = libinput_event_get_context(event); + char *event_str = libinput_event_to_str(event, 0, NULL); + log_debug(libinput, "Queuing %s\n", event_str); + free(event_str); +} + static void libinput_post_event(struct libinput *libinput, struct libinput_event *event) @@ -3183,19 +3194,7 @@ libinput_post_event(struct libinput *libinput, size_t new_out; #if 0 - char buf[1024] = { 0 }; - switch (event->type) { - case LIBINPUT_EVENT_POINTER_BUTTON: { - struct libinput_event_pointer *pev = libinput_event_get_pointer_event(event); - snprintf(buf, sizeof(buf), "button: %u, state %s", - libinput_event_pointer_get_button(pev), - libinput_event_pointer_get_button_state(pev) == LIBINPUT_BUTTON_STATE_PRESSED ? "press" : "released"); - break; - } - default: - break; - } - log_debug(libinput, "Queuing %s { %s }\n", event_type_to_str(event->type), buf); + libinput_print_queued_event(event); #endif events_count++;