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.
This commit is contained in:
Daniel Eklöf 2021-06-17 18:15:29 +02:00
parent 31e10c1613
commit 495c730487
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 380 additions and 276 deletions

40
input.c
View file

@ -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 */