+static int kbdctx_refresh_compose_table(kbdctx *kc, const char *lang) {
+ kbdtbl *kt;
+ idev_session *s;
+ idev_device *d;
+ Iterator i, j;
+ int r;
+
+ if (!lang)
+ lang = "C";
+
+ if (streq_ptr(kc->locale_lang, lang))
+ return 0;
+
+ r = free_and_strdup(&kc->locale_lang, lang);
+ if (r < 0)
+ return r;
+
+ log_debug("idev-keyboard: new default compose table: [ %s ]", lang);
+
+ r = kbdtbl_new_from_locale(&kt, kc, lang);
+ if (r < 0) {
+ /* TODO: We need to catch the case where no compose-file is
+ * available. xkb doesn't tell us so far.. so we must not treat
+ * 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));
+ r = 0;
+ kt = NULL;
+ }
+
+ kbdtbl_unref(kc->kbdtbl);
+ kc->kbdtbl = kt;
+
+ HASHMAP_FOREACH(s, kc->context->session_map, i)
+ HASHMAP_FOREACH(d, s->device_map, j)
+ if (idev_is_keyboard(d))
+ keyboard_update_kbdtbl(keyboard_from_device(d));
+
+ return 0;
+}
+