From 4c5f53878e6b7adcf34b2e634c60d58a75e9e238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 16 Dec 2021 12:37:58 +0100 Subject: [PATCH] =?UTF-8?q?input:=20kitty:=20don=E2=80=99t=20fallback=20to?= =?UTF-8?q?=20the=20XKB=20symbol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When handling “generic” keys (i.e. keys not in the Kitty keymap), we use the pressed key’s Unicode codepoint as “key” in the kitty CSI. If we failed to convert the XKB symbol to a Unicode codepoint, we used to (before this patch), fallback to using the XKB symbol as is. This can never be correct... and it caused us to emit a meaningless CSI for XKB_KEY_ISO_Next_Group, which confused e.g. Kakoune. --- CHANGELOG.md | 2 ++ input.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca3ca225..be8b02b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ * Font size adjustment (“zooming”) when font is configured with a **pixelsize**, and `dpi-aware=no` (https://codeberg.org/dnkl/foot/issues/842). +* Key presses triggering keyboard layout switches also being emitted + CSI codes in the Kitty keyboard protocol. ### Security diff --git a/input.c b/input.c index 13899b28..78e5017c 100644 --- a/input.c +++ b/input.c @@ -1329,7 +1329,7 @@ emit_escapes: else { key = xkb_keysym_to_utf32(sym_to_use); if (key == 0) - key = sym_to_use; + return false; /* The *shifted* key. May be the same as the unshifted * key - if so, this is filtered out below, when @@ -1349,6 +1349,9 @@ emit_escapes: final = 'u'; } + if (key < 0) + return false; + xassert(encoded_mods >= 1); char event[4]; @@ -1365,9 +1368,6 @@ emit_escapes: size_t left = sizeof(buf); size_t bytes; - if (key < 0) - return false; - if (final == 'u' || final == '~') { bytes = snprintf(p, left, "\x1b[%u", key); p += bytes; left -= bytes;