summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-03-16 16:08:32 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2013-11-03 12:25:18 +0100
commita11d71a987e4be099d87c21b31e7fa9f24eaa6ca (patch)
tree3497f51710605fdf1aec65e7fa6ba2e7223d9eef /src
parent4bcf5073022c2cefffb0bb51f95f1564e7e447be (diff)
uterm: input: forward xkbcommon log messages
Instead of letting xkbcommon write to stderr, we now forward these messages via the llog handler. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/uterm_input_uxkb.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/uterm_input_uxkb.c b/src/uterm_input_uxkb.c
index af6bd05..925c755 100644
--- a/src/uterm_input_uxkb.c
+++ b/src/uterm_input_uxkb.c
@@ -38,11 +38,48 @@
#include "uterm_input.h"
#include "uterm_input_internal.h"
-#define LLOG_SUBSYSTEM "uterm_input_uxkb"
+#define LLOG_SUBSYSTEM "uterm_uxkb"
extern const char _binary_src_uterm_input_fallback_xkb_bin_start[];
extern const char _binary_src_uterm_input_fallback_xkb_bin_end[];
+static void uxkb_log(struct xkb_context *context, enum xkb_log_level level,
+ const char *format, va_list args)
+{
+ struct uterm_input *input;
+ unsigned int sev;
+
+ input = xkb_context_get_user_data(context);
+ if (!input->llog)
+ return;
+
+ switch (level) {
+ case XKB_LOG_LEVEL_CRITICAL:
+ sev = LLOG_CRITICAL;
+ break;
+ case XKB_LOG_LEVEL_ERROR:
+ sev = LLOG_ERROR;
+ break;
+ case XKB_LOG_LEVEL_WARNING:
+ sev = LLOG_WARNING;
+ break;
+ case XKB_LOG_LEVEL_INFO:
+ sev = LLOG_INFO;
+ break;
+ case XKB_LOG_LEVEL_DEBUG:
+ /* fallthrough */
+ default:
+ sev = LLOG_DEBUG;
+ break;
+ }
+
+ input->llog(input->llog_data,
+ LLOG_DEFAULT,
+ sev,
+ format,
+ args);
+}
+
int uxkb_desc_init(struct uterm_input *input,
const char *model,
const char *layout,
@@ -68,6 +105,12 @@ int uxkb_desc_init(struct uterm_input *input,
return -ENOMEM;
}
+ /* Set logging function. You can use XKB_LOG_VERBOSITY and XKB_LOG_LEVEL
+ * to change the xkbcommon logger. That's why we don't touch the
+ * verbosity and level here. */
+ xkb_context_set_user_data(input->ctx, input);
+ xkb_context_set_log_fn(input->ctx, uxkb_log);
+
/* If a complete keymap file was given, first try that. */
if (keymap && *keymap) {
input->keymap = xkb_keymap_new_from_string(input->ctx,