input/keyboard: extend bindsym --to-code to work with duplicate matches

This modifies `get_active_binding` to treat bindsym --to-codes
separately: per each keysym `i` in `binding->keys`, look through the list of
matching keycodes in `binding->translations[i]`.

Another solution is to take the cartesian product of all syms and make a
binding per each product. This makes retranslation more difficult though
because the dups from the old layout have to be cleared out before
translating to the new `xkb_layout`. Whether by retaining a parent
binding, searching through all bindings for matching `binding->command`,
or some other ref count structure, that would introduce more complexity
than modifying get_active binding to account for dups. Notice this
requires no changes to the existing retranslation logic.
This commit is contained in:
Furkan Sahin 2024-09-23 16:07:01 -05:00 committed by Furkan Sahin
parent 8d3a52aa30
commit 1f559879c3
3 changed files with 73 additions and 66 deletions

View file

@ -62,7 +62,7 @@ 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
list_t **translations; // translations[i] = all keycodes for keysym keys[i]
uint32_t modifiers;
xkb_layout_index_t group;
char *command;