mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-26 06:46:45 -04:00
key-bindings: refactor: use a single type for all key bindings
Up until now, the various key binding modes (“normal”, “search” and “url”) have used their own struct definitions for their key bindings. The only reason for this was to have a properly typed “action” (using the appropriate “action” enum). This caused lots of duplicated code. This patch refactors this to use a single struct definition for the “unparsed” key bindings handled by the configuration, and another single definition for “parsed” bindings used while handling input. This allows us to implement configuration parsing, keymap translation and so on using one set of functions, regardless of key binding mode.
This commit is contained in:
parent
63a50afc8e
commit
03bac9dada
7 changed files with 145 additions and 331 deletions
23
wayland.c
23
wayland.c
|
|
@ -132,6 +132,15 @@ seat_add_text_input(struct seat *seat)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
key_bindings_destroy(key_binding_list_t *bindings)
|
||||
{
|
||||
tll_foreach(*bindings, it) {
|
||||
tll_free(it->item.key_codes);
|
||||
tll_remove(*bindings, it);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
seat_destroy(struct seat *seat)
|
||||
{
|
||||
|
|
@ -140,17 +149,9 @@ seat_destroy(struct seat *seat)
|
|||
|
||||
tll_free(seat->mouse.buttons);
|
||||
|
||||
tll_foreach(seat->kbd.bindings.key, it)
|
||||
tll_free(it->item.bind.key_codes);
|
||||
tll_free(seat->kbd.bindings.key);
|
||||
|
||||
tll_foreach(seat->kbd.bindings.search, it)
|
||||
tll_free(it->item.bind.key_codes);
|
||||
tll_free(seat->kbd.bindings.search);
|
||||
|
||||
tll_foreach(seat->kbd.bindings.url, it)
|
||||
tll_free(it->item.bind.key_codes);
|
||||
tll_free(seat->kbd.bindings.url);
|
||||
key_bindings_destroy(&seat->kbd.bindings.key);
|
||||
key_bindings_destroy(&seat->kbd.bindings.search);
|
||||
key_bindings_destroy(&seat->kbd.bindings.url);
|
||||
|
||||
tll_free(seat->mouse.bindings);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue