input: xkb: ignore virtual modifiers

Some compositors (mutter/GNOME is one) adds _virtual_ modifiers to the
set of active modifiers when e.g. Alt, Meta, Super or Hyper is
pressed. For example, pressing Alt+b would result in *both* the Alt
*and* the Mod1 modifier being set.

Since foot makes close to zero assumptions on how the modifiers should
be interpreted, this causes various breakages.

For example, a foot shortcut defined as Mod1+b will not match, since
the Alt modifiers is also set. This has forced users to
redefine/override some of the default key bindings to include the
additional modifiers.

It also causes issues with the kitty keyboard protocol, for some key
combinations. Mainly whether or not to use unshifted key or not,
resulting in incorrect escape sequences.

Since all the "real" modifiers are always set as well, we can safely
ignore the virtual modifiers.

Closes #2009
This commit is contained in:
Daniel Eklöf 2025-03-29 10:34:40 +01:00
parent c8470f40c1
commit 58910856c8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 66 additions and 0 deletions

View file

@ -136,6 +136,8 @@ struct seat {
xkb_mod_mask_t legacy_significant; /* Significant modifiers for the legacy keyboard protocol */
xkb_mod_mask_t kitty_significant; /* Significant modifiers for the kitty keyboard protocol */
xkb_mod_mask_t virtual_modifiers; /* Set of modifiers to completely ignore */
xkb_keycode_t key_arrow_up;
xkb_keycode_t key_arrow_down;