diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-06-17 16:15:29 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-06-18 13:35:57 +0000 |
| commit | 495c7304878bdd010dc5d25620dc68f41ac4cd36 (patch) | |
| tree | cf2c04fafcea5396778f3063efd0df3c042ace0a /input.c | |
| parent | Merge branch 'footclient-dont-copy-conf-unless-necessary' (diff) | |
config: don’t use tllist where it isn’t necessary
tllists are great when dealing with dynamically changing lists. They
are also very easy to use when building lists/arrays where the final
size is unknown.
However, this ease of use comes at a price: code size. tll-macros
expand to a lot of code.
Since things in the config are static, once the config has been
loaded, using tllists for configuration data structures doesn’t make
much sense.
This patch replaces nearly all tllists used by the configuration, with
dynamically allocated arrays.
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 40 |
1 files changed, 30 insertions, 10 deletions
@@ -527,22 +527,36 @@ convert_key_binding(const struct seat *seat, static void convert_key_bindings(const struct config *conf, struct seat *seat) { - tll_foreach(conf->bindings.key, it) - convert_key_binding(seat, &it->item, &seat->kbd.bindings.key); + for (size_t i = 0; i < conf->bindings.key.count; i++) { + const struct config_key_binding *binding = &conf->bindings.key.arr[i]; + if (binding->action == BIND_ACTION_NONE) + continue; + convert_key_binding(seat, binding, &seat->kbd.bindings.key); + } } static void convert_search_bindings(const struct config *conf, struct seat *seat) { - tll_foreach(conf->bindings.search, it) - convert_key_binding(seat, &it->item, &seat->kbd.bindings.search); + for (size_t i = 0; i < conf->bindings.search.count; i++) { + const struct config_key_binding *binding = &conf->bindings.search.arr[i]; + if (binding->action == BIND_ACTION_SEARCH_NONE) + continue; + convert_key_binding(seat, binding, &seat->kbd.bindings.search); + } } static void convert_url_bindings(const struct config *conf, struct seat *seat) { - tll_foreach(conf->bindings.url, it) - convert_key_binding(seat, &it->item, &seat->kbd.bindings.url); + for (size_t i = 0; i < conf->bindings.url.count; i++) { + const struct config_key_binding *binding = &conf->bindings.url.arr[i]; +#if 0 + if (binding->action == BIND_ACTION_URL_NONE) + continue; +#endif + convert_key_binding(seat, binding, &seat->kbd.bindings.url); + } } static void @@ -562,8 +576,12 @@ convert_mouse_binding(struct seat *seat, static void convert_mouse_bindings(const struct config *conf, struct seat *seat) { - tll_foreach(conf->bindings.mouse, it) - convert_mouse_binding(seat, &it->item); + for (size_t i = 0; i < conf->bindings.mouse.count; i++) { + const struct config_mouse_binding *binding = &conf->bindings.mouse.arr[i]; + if (binding->action == BIND_ACTION_NONE) + continue; + convert_mouse_binding(seat, binding); + } } static void @@ -1924,9 +1942,11 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, else { /* Seat does NOT have a keyboard - use mouse bindings *without* modifiers */ const struct config_mouse_binding *match = NULL; + const struct config *conf = seat->wayl->conf; - tll_foreach(seat->wayl->conf->bindings.mouse, it) { - const struct config_mouse_binding *binding = &it->item; + for (size_t i = 0; i < conf->bindings.mouse.count; i++) { + const struct config_mouse_binding *binding = + &conf->bindings.mouse.arr[i]; if (binding->button != button) { /* Wrong button */ |
