keybind: refactor update_keycodes_iter() to reduce nesting

update_keycodes_iter() currently has 4(!) levels of nested loops, which
makes the logic (especially the break/continue statements) difficult to
understand. The logic also appears to continue looping uselessly after
a given keycode has already been added to a keybind.

Refactor by adding some small utility functions:

- keybind_contains_keycode()
- keybind_contains_keysym()
- keybind_contains_any_keysym()

No functional change intended.
This commit is contained in:
John Lindgren 2025-08-16 13:17:36 -04:00 committed by Johan Malm
parent 28513cbdbe
commit 6574c82aed
3 changed files with 56 additions and 33 deletions

View file

@ -41,5 +41,8 @@ uint32_t parse_modifier(const char *symname);
bool keybind_the_same(struct keybind *a, struct keybind *b);
bool keybind_contains_keycode(struct keybind *keybind, xkb_keycode_t keycode);
bool keybind_contains_keysym(struct keybind *keybind, xkb_keysym_t keysym);
void keybind_update_keycodes(struct server *server);
#endif /* LABWC_KEYBIND_H */