config/bindings: Extend bindsym --to-code to additionally

handle the case in which a given keysym maps to more than
one keycode.

Sometimes, a keysym can map to duplicate keycodes and `libxkbcommon`
does not prohibit this. In that case, it makes sense to
find all the keycodes that map to the keysym.

- Merges translate_binding into translate_keysyms, simplify logic
- Changes add_matching_keycodes to find ALL keycodes, not just last
- Removes unncessary list_t* syms. It's only used to alias keys as
  "syms". No other purpose.

This commit also introduces a recursive cartesian product
calculator in order to handle any cases.

`bindsym --to-code (M + .. + N)` s.t.
Keysym M maps to keycodes { M_0 .. M_m }
...
Keysym N maps to keycodes { N_0 .. N_n }
results in || M x .. x N || bindings (cartesian product)
This commit is contained in:
Furkan Sahin 2024-09-14 21:22:21 -05:00
parent f957c7e658
commit 052d905fc7
3 changed files with 111 additions and 98 deletions

View file

@ -62,7 +62,6 @@ struct sway_binding {
char *input;
uint32_t flags;
list_t *keys; // sorted in ascending order
list_t *syms; // sorted in ascending order; NULL if BINDING_CODE is not set
uint32_t modifiers;
xkb_layout_index_t group;
char *command;