* it as a hard-failure but just continue. Preferably, we want
* xkb to tell us exactly whether compilation failed or whether
* there is no compose file available for this locale. */
- log_debug("idev-keyboard: cannot load compose-table for '%s': %s",
- lang, strerror(-r));
+ log_debug_errno(r, "idev-keyboard: cannot load compose-table for '%s': %m",
+ lang);
r = 0;
kt = NULL;
}
/* TODO: add a fallback keymap that's compiled-in */
r = kbdmap_new_from_names(&km, kc, kc->last_x11_model, kc->last_x11_layout,
kc->last_x11_variant, kc->last_x11_options);
- if (r < 0) {
- log_debug("idev-keyboard: cannot create keymap from locale1: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "idev-keyboard: cannot create keymap from locale1: %m");
kbdmap_unref(kc->kbdmap);
kc->kbdmap = km;
error:
if (r < 0)
- log_debug("idev-keyboard: cannot parse locale property from locale1: %s", strerror(-r));
+ log_debug_errno(r, "idev-keyboard: cannot parse locale property from locale1: %m");
return r;
}
return 0;
error:
- log_debug("idev-keyboard: cannot send GetAll to locale1: %s", strerror(-r));
- return r;
+ return log_debug_errno(r, "idev-keyboard: cannot send GetAll to locale1: %m");
}
static int kbdctx_locale_props_changed_fn(sd_bus *bus,
return 0;
error:
- log_debug("idev-keyboard: cannot handle PropertiesChanged from locale1: %s", strerror(-r));
- return r;
+ return log_debug_errno(r, "idev-keyboard: cannot handle PropertiesChanged from locale1: %m");
}
static int kbdctx_setup_bus(kbdctx *kc) {
"path='/org/freedesktop/locale1'",
kbdctx_locale_props_changed_fn,
kc);
- if (r < 0) {
- log_debug("idev-keyboard: cannot setup locale1 link: %s", strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_debug_errno(r, "idev-keyboard: cannot setup locale1 link: %m");
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_internalv(sd_lvl, 0, __FILE__, __LINE__, __func__, buf, args);
+}
+
static kbdctx *kbdctx_ref(kbdctx *kc) {
assert_return(kc, NULL);
assert_return(kc->ref > 0, NULL);
kc->context = c;
errno = 0;
- kc->xkb_context = xkb_context_new(0);
+ kc->xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
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;
r = idev_session_raise_device_data(d->session, d, data);
if (r < 0)
- log_debug("idev-keyboard: %s/%s: error while raising data event: %s",
- d->session->name, d->name, strerror(-r));
+ log_debug_errno(r, "idev-keyboard: %s/%s: error while raising data event: %m",
+ d->session->name, d->name);
return r;
}
r = keyboard_fill(k, repdata, false, evkbd->keycode, KBDKEY_REPEAT, num, keysyms);
if (r < 0) {
- log_debug("idev-keyboard: %s/%s: cannot set key-repeat: %s",
- d->session->name, d->name, strerror(-r));
+ log_debug_errno(r, "idev-keyboard: %s/%s: cannot set key-repeat: %m",
+ d->session->name, d->name);
k->repeating = false;
keyboard_arm(k, 0);
} else {
r = keyboard_fill(k, repdata, false, repkbd->keycode, KBDKEY_REPEAT, num, keysyms);
if (r < 0) {
- log_debug("idev-keyboard: %s/%s: cannot update key-repeat: %s",
- d->session->name, d->name, strerror(-r));
+ log_debug_errno(r, "idev-keyboard: %s/%s: cannot update key-repeat: %m",
+ d->session->name, d->name);
k->repeating = false;
keyboard_arm(k, 0);
}
return keyboard_raise_data(k, &k->evdata);
error:
- log_debug("idev-keyboard: %s/%s: cannot handle event: %s",
- d->session->name, d->name, strerror(-r));
+ log_debug_errno(r, "idev-keyboard: %s/%s: cannot handle event: %m",
+ d->session->name, d->name);
k->repeating = false;
keyboard_arm(k, 0);
return 0;
return 0;
error:
- log_debug("idev-keyboard: %s/%s: cannot adopt new keymap: %s",
- d->session->name, d->name, strerror(-r));
- return r;
+ return log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new keymap: %m",
+ d->session->name, d->name);
}
static int keyboard_update_kbdtbl(idev_keyboard *k) {
return 0;
error:
- log_debug("idev-keyboard: %s/%s: cannot adopt new compose table: %s",
- d->session->name, d->name, strerror(-r));
- return r;
+ return log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new compose table: %m",
+ d->session->name, d->name);
}
static const idev_device_vtable keyboard_vtable = {