input: must have all required modifiers to un-shift a symbol

When detecting, and repairing, “broken” key bindings (where the key
binding itself explicitly lists a modifier that is consumed by the
final symbol - e.g “Shift+W”), don’t just look for an intersection
between the set of modifiers needed to produce the final symbol, and
the modifiers listed in the key combo. Instead, check if the key combo
has *all* the required modifiers.

Example: Shift+AltGr+w produces Page_Down. I.e. Page_Down is the
_shifted_ symbol, ‘w’ is the un-shifted symbol, and Shift+AltGr are
the modifiers required to shift ‘w’ to Page_Down.

If we have the key combo Shift+Page_Down, foot would, correctly,
determine that Page_Down is a shifted symbol. It would find the
Shift+AltGr modifier set, and since the intersection of “Shift+AltGr”
and “Shift” (from our key combo) is non-empty, foot
would (incorrectly) determine that we can, and should, replace
Page_Down with its un-shifted symbol ‘w’.

This is completely wrong, since Shift+w does _not_ produce Page_Down.

Closes #407
This commit is contained in:
Daniel Eklöf 2021-03-21 11:55:03 +01:00
parent eccf2b674e
commit 0c85905972
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 6 additions and 1 deletions

View file

@ -30,6 +30,11 @@
### Deprecated
### Removed
### Fixed
* Logic that repairs invalid key bindings ended up breaking valid key
bindings instead (https://codeberg.org/dnkl/foot/issues/407).
### Security
### Contributors

View file

@ -450,7 +450,7 @@ maybe_repair_key_combo(const struct seat *seat,
/* Check if key combos modifier set intersects */
for (size_t j = 0; j < mod_mask_count; j++) {
if (!(mod_masks[j] & mods))
if ((mod_masks[j] & mods) != mod_masks[j])
continue;
char combo[64] = {0};