summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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,