From 2f0dd5164d36956197b9e649a100d5cfe08bb247 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 25 Nov 2014 10:24:39 +0100 Subject: terminal/idev: forward xkb-messages Properly forward all XKB messages. You can use XKB_LOG_VERBOSITY= to control the amount of messages sent by XKB. We explicitly set XKB_LOG_LEVEL to 7 you can use SYSTEMD_LOG_LEVEL to control the log-level generically. --- src/libsystemd-terminal/idev-keyboard.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/libsystemd-terminal') diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c index c690c6647f..ad2d74af15 100644 --- a/src/libsystemd-terminal/idev-keyboard.c +++ b/src/libsystemd-terminal/idev-keyboard.c @@ -504,6 +504,27 @@ static int kbdctx_setup_bus(kbdctx *kc) { return kbdctx_query_locale(kc); } +static void kbdctx_log_fn(struct xkb_context *ctx, enum xkb_log_level lvl, const char *format, va_list args) { + char buf[LINE_MAX]; + int sd_lvl; + + if (lvl >= XKB_LOG_LEVEL_DEBUG) + sd_lvl = LOG_DEBUG; + else if (lvl >= XKB_LOG_LEVEL_INFO) + sd_lvl = LOG_INFO; + else if (lvl >= XKB_LOG_LEVEL_WARNING) + sd_lvl = LOG_INFO; /* most XKB warnings really are informational */ + else if (lvl >= XKB_LOG_LEVEL_ERROR) + sd_lvl = LOG_ERR; + else if (lvl >= XKB_LOG_LEVEL_CRITICAL) + sd_lvl = LOG_CRIT; + else + sd_lvl = LOG_CRIT; + + snprintf(buf, sizeof(buf), "idev-xkb: %s", format); + log_metav(sd_lvl, __FILE__, __LINE__, __func__, buf, args); +} + static kbdctx *kbdctx_ref(kbdctx *kc) { assert_return(kc, NULL); assert_return(kc->ref > 0, NULL); @@ -562,6 +583,9 @@ static int kbdctx_new(kbdctx **out, idev_context *c) { if (!kc->xkb_context) return errno > 0 ? -errno : -EFAULT; + xkb_context_set_log_fn(kc->xkb_context, kbdctx_log_fn); + xkb_context_set_log_level(kc->xkb_context, XKB_LOG_LEVEL_DEBUG); + r = kbdctx_refresh_keymap(kc); if (r < 0) return r; -- cgit v1.2.3-54-g00ecf