chiark / gitweb /
keymap: Ignore brightness keys on Dell Inspiron 1520 to avoid double events
[elogind.git] / src / libsystemd-terminal / idev-keyboard.c
index 7ab4db2cf79ed8ec71af8a25279cd76ae731ddf9..8dc1c20b1430f8ee29c751cfda57f36dcd37c27a 100644 (file)
@@ -317,11 +317,14 @@ static int kbdctx_locale_props_changed_fn(sd_bus *bus,
 
         kc->slot_locale_get_all = sd_bus_slot_unref(kc->slot_locale_get_all);
 
+        /* skip interface name */
+        r = sd_bus_message_skip(signal, "s");
+        if (r < 0)
+                goto error;
+
         r = bus_message_map_properties_changed(bus, signal, kbdctx_locale_map, kc);
-        if (r < 0) {
-                log_debug("idev-keyboard: cannot handle PropertiesChanged from locale1: %s", strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                goto error;
 
         if (r > 0) {
                 r = kbdctx_query_locale(kc);
@@ -331,6 +334,10 @@ static int kbdctx_locale_props_changed_fn(sd_bus *bus,
 
         kbdctx_refresh_keymap(kc);
         return 0;
+
+error:
+        log_debug("idev-keyboard: cannot handle PropertiesChanged from locale1: %s", strerror(-r));
+        return r;
 }
 
 static int kbdctx_setup_bus(kbdctx *kc) {
@@ -550,6 +557,7 @@ int idev_keyboard_new(idev_device **out, idev_session *s, const char *name) {
 static void keyboard_free(idev_device *d) {
         idev_keyboard *k = keyboard_from_device(d);
 
+        xkb_state_unref(k->xkb_state);
         free(k->repdata.keyboard.codepoints);
         free(k->repdata.keyboard.keysyms);
         free(k->evdata.keyboard.codepoints);
@@ -567,7 +575,7 @@ static int8_t guess_ascii(struct xkb_state *state, uint32_t code, uint32_t n_sym
         const xkb_keysym_t *s;
         int num;
 
-        if (n_syms == 1 && syms[0] < 128)
+        if (n_syms == 1 && syms[0] < 128 && syms[0] > 0)
                 return syms[0];
 
         keymap = xkb_state_get_keymap(state);
@@ -576,7 +584,7 @@ static int8_t guess_ascii(struct xkb_state *state, uint32_t code, uint32_t n_sym
         for (lo = 0; lo < n_lo; ++lo) {
                 lv = xkb_state_key_get_level(state, code + KBDXKB_SHIFT, lo);
                 num = xkb_keymap_key_get_syms_by_level(keymap, code + KBDXKB_SHIFT, lo, lv, &s);
-                if (num == 1 && s[0] < 128)
+                if (num == 1 && s[0] < 128 && s[0] > 0)
                         return s[0];
         }
 
@@ -762,8 +770,10 @@ static int keyboard_feed_evdev(idev_keyboard *k, idev_data *data) {
                 /* TODO: update LEDs */
         }
 
-        if (num < 0)
+        if (num < 0) {
+                r = num;
                 goto error;
+        }
 
         r = keyboard_fill(k, &k->evdata, data->resync, ev->code, ev->value, num, keysyms);
         if (r < 0)