From 576da9db26d4241dfede0310eef665d5a63ddb94 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 19 Nov 2014 11:42:04 +1000 Subject: [PATCH] Hook up the libinput log handler Let the server filter based on the verbosity levels in the server, so map ERROR to -1 (always), INFO to 3 (default verbosity) and DEBUG to 10. Signed-off-by: Peter Hutterer --- src/libinput.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/libinput.c b/src/libinput.c index c8d36a6..ef9d652 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -632,6 +632,45 @@ const struct libinput_interface interface = { .close_restricted = close_restricted, }; +static void +xf86libinput_log_handler(struct libinput *libinput, + enum libinput_log_priority priority, + const char *format, + va_list args) + _X_ATTRIBUTE_PRINTF(3, 0); + +static void +xf86libinput_log_handler(struct libinput *libinput, + enum libinput_log_priority priority, + const char *format, + va_list args) +{ + MessageType type; + int verbosity; + + switch(priority) { + case LIBINPUT_LOG_PRIORITY_DEBUG: + type = X_DEBUG; + verbosity = 10; + break; + case LIBINPUT_LOG_PRIORITY_ERROR: + type = X_ERROR; + verbosity = -1; + break; + case LIBINPUT_LOG_PRIORITY_INFO: + type = X_INFO; + verbosity = 3; + break; + default: + return; + } + + /* log messages in libinput are per-context, not per device, so we + can't use xf86IDrvMsg here, and the server has no xf86VMsg or + similar */ + LogVMessageVerb(type, verbosity, format, args); +} + static int xf86libinput_pre_init(InputDriverPtr drv, InputInfoPtr pInfo, int flags) @@ -663,10 +702,16 @@ static int xf86libinput_pre_init(InputDriverPtr drv, if (!path) goto fail; - if (!driver_context.libinput) + if (!driver_context.libinput) { driver_context.libinput = libinput_path_create_context(&interface, &driver_context); - else + libinput_log_set_handler(driver_context.libinput, + xf86libinput_log_handler); + /* we want all msgs, let the server filter */ + libinput_log_set_priority(driver_context.libinput, + LIBINPUT_LOG_PRIORITY_DEBUG); + } else { libinput_ref(driver_context.libinput); + } libinput = driver_context.libinput;