Do not include consumed modifiers in key escape sequences sent to the client application #378

Manually merged
dnkl merged 2 commits from consume-modifiers-for-client-application into master 11 months ago
  1. 2
      CHANGELOG.md
  2. 14
      input.c
  3. 19
      keymap.h

2
CHANGELOG.md

@ -78,6 +78,8 @@
**must** now be written as either `Control+C` or `Control+Shift+c`,
the latter being the preferred
variant. (https://codeberg.org/dnkl/foot/issues/376)
* Consumed modifiers are no longer sent to the client application
(https://codeberg.org/dnkl/foot/issues/376).
* The minimum version requirement for the libxkbcommon dependency is
now 1.0.0.

14
input.c

@ -770,8 +770,8 @@ keymap_data_for_sym(xkb_keysym_t sym, size_t *count)
switch (sym) {
case XKB_KEY_Escape: *count = ALEN(key_escape); return key_escape;
case XKB_KEY_Return: *count = ALEN(key_return); return key_return;
case XKB_KEY_Tab: /* FALLTHROUGH */
case XKB_KEY_ISO_Left_Tab: *count = ALEN(key_tab); return key_tab;
case XKB_KEY_ISO_Left_Tab: *count = ALEN(key_iso_left_tab); return key_iso_left_tab;
case XKB_KEY_Tab: *count = ALEN(key_tab); return key_tab;
case XKB_KEY_BackSpace: *count = ALEN(key_backspace); return key_backspace;
case XKB_KEY_Up: *count = ALEN(key_up); return key_up;
case XKB_KEY_Down: *count = ALEN(key_down); return key_down;
@ -1026,10 +1026,10 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
*/
enum modifier keymap_mods = MOD_NONE;
keymap_mods |= seat->kbd.shift ? MOD_SHIFT : MOD_NONE;
keymap_mods |= seat->kbd.alt ? MOD_ALT : MOD_NONE;
keymap_mods |= seat->kbd.ctrl ? MOD_CTRL : MOD_NONE;
keymap_mods |= seat->kbd.meta ? MOD_META : MOD_NONE;
keymap_mods |= mods & ~consumed & shift ? MOD_SHIFT : MOD_NONE;
keymap_mods |= mods & ~consumed & alt ? MOD_ALT : MOD_NONE;
keymap_mods |= mods & ~consumed & ctrl ? MOD_CTRL : MOD_NONE;
keymap_mods |= mods & ~consumed & meta ? MOD_META : MOD_NONE;
const struct key_data *keymap;
if (sym == XKB_KEY_Escape && keymap_mods == MOD_NONE && term->modify_escape_key) {
@ -1113,7 +1113,7 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
}
else {
if (mods & alt) {
if (mods & ~consumed & alt) {
/*
* When the alt modifier is pressed, we do one out of three things:
*

19
keymap.h

@ -78,6 +78,25 @@ static const struct key_data key_tab[] = {
{MOD_ANY, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\t"},
};
/*
* Shift+Tab produces ISO_Left_Tab
*
* However, all combos (except Shift+Tab) acts as if we pressed
* mods+shift+tab. XKB consumes shift for us, hence MOD_SHIFT isnt
* present in any of the entries below. However, the entries still map
* to sequences that indicate shift has been pressed.
*/
static const struct key_data key_iso_left_tab[] = {
{MOD_ALT, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033[27;4;9~"},
{MOD_CTRL, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033[27;6;9~"},
{MOD_ALT | MOD_CTRL, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033[27;8;9~"},
{MOD_META, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033[27;10;9~"},
{MOD_META | MOD_ALT, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033[27;12;9~"},
{MOD_META | MOD_CTRL, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033[27;14;9~"},
{MOD_META | MOD_ALT | MOD_CTRL, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033[27;16;9~"},
{MOD_ANY, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033[Z"},
};
static const struct key_data key_backspace[] = {
{MOD_SHIFT, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\x7f"},
{MOD_ALT, CURSOR_KEYS_DONTCARE, KEYPAD_DONTCARE, "\033\x7f"},

Loading…
Cancel
Save