diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-02-06 11:11:51 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-02-06 11:11:51 +0000 |
| commit | 0f10c4fd6cd4c0be4e251d0b9d01fedb7ad087a2 (patch) | |
| tree | 907a139df272dd079406ca581d286969989f7f69 /key-binding.c | |
| parent | feature: add resize-by-cells option to constrain window sizes... (diff) | |
| parent | changelog: custom modifiers in key bindings (diff) | |
Merge branch 'modifiers'
Closes #1348
Diffstat (limited to 'key-binding.c')
| -rw-r--r-- | key-binding.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/key-binding.c b/key-binding.c index 1dffd3ee..a7738da8 100644 --- a/key-binding.c +++ b/key-binding.c @@ -404,6 +404,24 @@ sort_binding_list(key_binding_list_t *list) tll_sort(*list, key_cmp); } +static xkb_mod_mask_t +mods_to_mask(const struct seat *seat, const config_modifier_list_t *mods) +{ + xkb_mod_mask_t mask = 0; + tll_foreach(*mods, it) { + xkb_mod_index_t idx = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, it->item); + + if (idx == XKB_MOD_INVALID) { + LOG_ERR("%s: invalid modifier name", it->item); + continue; + } + + mask |= 1 << idx; + } + + return mask; +} + static void NOINLINE convert_key_binding(struct key_set *set, const struct config_key_binding *conf_binding, @@ -411,7 +429,7 @@ convert_key_binding(struct key_set *set, { const struct seat *seat = set->seat; - xkb_mod_mask_t mods = conf_modifiers_to_mask(seat, &conf_binding->modifiers); + xkb_mod_mask_t mods = mods_to_mask(seat, &conf_binding->modifiers); xkb_keysym_t sym = maybe_repair_key_combo(seat, conf_binding->k.sym, mods); struct key_binding binding = { @@ -469,7 +487,7 @@ convert_mouse_binding(struct key_set *set, .type = MOUSE_BINDING, .action = conf_binding->action, .aux = &conf_binding->aux, - .mods = conf_modifiers_to_mask(set->seat, &conf_binding->modifiers), + .mods = mods_to_mask(set->seat, &conf_binding->modifiers), .m = { .button = conf_binding->m.button, .count = conf_binding->m.count, @@ -509,7 +527,7 @@ load_keymap(struct key_set *set) convert_url_bindings(set); convert_mouse_bindings(set); - set->public.selection_overrides = conf_modifiers_to_mask( + set->public.selection_overrides = mods_to_mask( set->seat, &set->conf->mouse.selection_override_modifiers); } |
