From e744cee7604eb0a98c4468d9f2160f440b851c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 21 Nov 2021 11:38:36 +0100 Subject: [PATCH] input: kitty: printables are emitted as text, even if Caps- or Num-Lock is in effect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not sure if this is the best/correct way to do it. But kitty seems to ignore at least Num-Lock for printables, while it _does_ affect other keys. For example, Return, which usually emits ‘\r’, are affected by Num-Lock and emit ‘CSI 13;129u’. Note that as soon as some other modifier is in effect, the Num-Lock modifier *is* encoded in the CSI, also for printables. --- input.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/input.c b/input.c index c55bab3d..6a1c29bc 100644 --- a/input.c +++ b/input.c @@ -1145,11 +1145,22 @@ kitty_kbd_protocol(struct seat *seat, struct terminal *term, case XKB_KEY_BackSpace: term_to_slave(term, "\x7f", 1); return; case XKB_KEY_Tab: term_to_slave(term, "\t", 1); return; } + } - if (iswprint(utf32)) { - term_to_slave(term, utf8, count); - return; - } + /* + * Printables without any modifiers are printed as is. + * + * TODO: plain text keys (a-z, 0-9 etc) are still printed as text, + * even when NumLock is active, despite NumLock being a + * significant modifier, *and* despite NumLock affecting other + * keys, like Return and Backspace; figure out if there’s some + * better magic than filtering out Caps- and Num-Lock here.. + */ + if (iswprint(utf32) && (effective & ~(1 << seat->kbd.mod_caps | + 1 << seat->kbd.mod_num)) == 0) + { + term_to_slave(term, utf8, count); + return; } unsigned int encoded_mods = 0;