diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-12-06 20:04:38 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-12-11 19:19:11 +0000 |
| commit | f6a591b80a820ae5ab6886eb9ba43c90986f302b (patch) | |
| tree | 142fc28bab22e058505cccb6fe104442b64ebe01 /input.c | |
| parent | config: do mouse binding collision detection after loading the conf (diff) | |
config: unify key- and mouse bindings
With this patch, key- and mouse-bindings structs (the non-layout
specific ones) are unified into a single struct.
The logic that parses, and manages, the key- and mouse binding lists
are almost identical. The *only* difference between a key- and a mouse
binding is that key bindings have an XKB symbol, and mouse bindings a
button and click-count.
The new, unified, struct uses a union around these, and all functions
that need to know which members to use/operate on now takes a ‘type’
parameter.
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -520,7 +520,7 @@ convert_key_binding(const struct seat *seat, key_binding_list_t *bindings) { xkb_mod_mask_t mods = conf_modifiers_to_mask(seat, &conf_binding->modifiers); - xkb_keysym_t sym = maybe_repair_key_combo(seat, conf_binding->sym, mods); + xkb_keysym_t sym = maybe_repair_key_combo(seat, conf_binding->k.sym, mods); struct key_binding binding = { .mods = mods, @@ -561,13 +561,13 @@ convert_url_bindings(const struct config *conf, struct seat *seat) static void convert_mouse_binding(struct seat *seat, - const struct config_mouse_binding *conf_binding) + const struct config_key_binding *conf_binding) { struct mouse_binding binding = { .action = conf_binding->action, .mods = conf_modifiers_to_mask(seat, &conf_binding->modifiers), - .button = conf_binding->button, - .count = conf_binding->count, + .button = conf_binding->m.button, + .count = conf_binding->m.count, .pipe_argv = conf_binding->pipe.argv.args, }; tll_push_back(seat->mouse.bindings, binding); @@ -577,9 +577,7 @@ static void convert_mouse_bindings(const struct config *conf, struct seat *seat) { 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; + const struct config_key_binding *binding = &conf->bindings.mouse.arr[i]; convert_mouse_binding(seat, binding); } } @@ -2543,19 +2541,19 @@ 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_key_binding *match = NULL; const struct config *conf = seat->wayl->conf; for (size_t i = 0; i < conf->bindings.mouse.count; i++) { - const struct config_mouse_binding *binding = + const struct config_key_binding *binding = &conf->bindings.mouse.arr[i]; - if (binding->button != button) { + if (binding->m.button != button) { /* Wrong button */ continue; } - if (binding->count > seat->mouse.count) { + if (binding->m.count > seat->mouse.count) { /* Incorrect click count */ continue; } @@ -2566,7 +2564,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, continue; } - if (match == NULL || binding->count > match->count) + if (match == NULL || binding->m.count > match->m.count) match = binding; } |
