dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
Blob Blame History Raw
From fe741a85c1912ead26c1a78251e1d490a8a432b3 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Fri, 3 Oct 2014 12:48:36 +0200
Subject: [PATCH] terminal/idev: don't map XKB_KEY_NoSymbol as ASCII 0

XKB_KEY_NoSymbol is defined as 0 but does not correspond to a VT key with
ASCII value 0. No such key exists, so don't try to find such a key.
---
 src/libsystemd-terminal/idev-keyboard.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c
index d5936b7d23..8dc1c20b14 100644
--- a/src/libsystemd-terminal/idev-keyboard.c
+++ b/src/libsystemd-terminal/idev-keyboard.c
@@ -575,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);
@@ -584,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];
         }