Keyboard protocol: Fix the Enter Tab and Backspace keys generating spurious release events even when report all keys as escape codes is not set

Fixes #7136
This commit is contained in:
Kovid Goyal 2024-02-18 11:12:24 +05:30
parent d35f391725
commit b2391553f9
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 21 additions and 3 deletions

View file

@ -43,6 +43,14 @@ The :doc:`ssh kitten <kittens/ssh>` is redesigned with powerful new features:
Detailed list of changes
-------------------------------------
0.33.0 [future]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Keyboard protocol: Fix the :kbd:`Enter`, :kbd:`Tab` and :kbd:`Backspace` keys
generating spurious release events even when report all keys as escape codes
is not set (:iss:`7136`)
0.32.2 [2024-02-12]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -348,6 +348,13 @@ and key release events. Normally only key press events are reported and key
repeat events are treated as key press events. See :ref:`event_types` for
details on how these are reported.
.. note::
The :kbd:`Enter`, :kbd:`Tab` and :kbd:`Backspace` keys will not have release
events unless :ref:`report_all_keys` 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.
.. _report_alternates:
Report alternate keys

View file

@ -176,9 +176,9 @@ encode_function_key(const KeyEvent *ev, char *output) {
}
if (!ev->report_text) {
switch(key_number) {
case GLFW_FKEY_ENTER: SIMPLE("\r");
case GLFW_FKEY_BACKSPACE: SIMPLE("\x7f");
case GLFW_FKEY_TAB: SIMPLE("\t");
case GLFW_FKEY_ENTER: if (ev->action == RELEASE) return -1; SIMPLE("\r");
case GLFW_FKEY_BACKSPACE: if (ev->action == RELEASE) return -1; SIMPLE("\x7f");
case GLFW_FKEY_TAB: if (ev->action == RELEASE) return -1; SIMPLE("\t");
default: break;
}
}

View file

@ -438,6 +438,9 @@ def mkp(name, *a, **kw):
ae(tq(ord('a'), action=defines.GLFW_REPEAT), csi(num='a', action=2))
ae(tq(ord('a'), action=defines.GLFW_RELEASE), csi(num='a', action=3))
ae(tq(ord('a'), action=defines.GLFW_RELEASE, mods=shift), csi(shift, num='a', action=3))
tq = partial(enc, key_encoding_flags=0b11)
ae(tq(defines.GLFW_FKEY_BACKSPACE), '\x7f')
ae(tq(defines.GLFW_FKEY_BACKSPACE, action=release), '')
# test alternate key reporting
aq = partial(enc, key_encoding_flags=0b100)