From e851d44ac949df533a31b7e40a6ab5752dac79f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 1 Jan 2025 08:06:52 +0100 Subject: [PATCH] kitty kbd: don't generate release events for plain Enter+Tab+Backspace From the specification: The Enter, Tab and Backspace keys will not have release events unless Report all keys as escape codes is also set, so that the user can still type reset at a shell prompt when a program that sets this mode ends without resetting it. Closes #1892 --- CHANGELOG.md | 4 ++++ input.c | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbe24067..1eb95c14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,8 +79,12 @@ support ([#1865][1865]). * Run-time changes to the window title, and the app ID now require the new value to consist of printable characters only. +* Kitty keyboard protocol: Enter, Tab and Backspace no longer report + _release_ events unless _"Report all keys as escape codes"_ is + enabled ([#1892][1892]). [1865]: https://codeberg.org/dnkl/foot/issues/1865 +[1892]: https://codeberg.org/dnkl/foot/issues/1892 ### Deprecated diff --git a/input.c b/input.c index 201f5c69..51425a36 100644 --- a/input.c +++ b/input.c @@ -1236,9 +1236,20 @@ kitty_kbd_protocol(struct seat *seat, struct terminal *term, if ((mods & ~locked & ~consumed) == 0) { switch (sym) { - case XKB_KEY_Return: term_to_slave(term, "\r", 1); return true; - case XKB_KEY_BackSpace: term_to_slave(term, "\x7f", 1); return true; - case XKB_KEY_Tab: term_to_slave(term, "\t", 1); return true; + case XKB_KEY_Return: + if (!released) + term_to_slave(term, "\r", 1); + return true; + + case XKB_KEY_BackSpace: + if (!released) + term_to_slave(term, "\x7f", 1); + return true; + + case XKB_KEY_Tab: + if (!released) + term_to_slave(term, "\t", 1); + return true; } }