diff options
| author | feeptr@codeberg.org <feeptr> | 2021-11-29 22:06:35 +0000 |
|---|---|---|
| committer | feeptr@codeberg.org <feeptr> | 2021-12-02 23:47:41 +0000 |
| commit | b52cd67467cb5e5f334f00680b42f8e071be1e79 (patch) | |
| tree | fc59069b129ca40a83b51f5d6671b7c9de5ea51c /config.c | |
| parent | config: parse 'none' as empty modifiers value (diff) | |
config, doc, changelog: move selection-override-modifiers to [mouse-bindings] and validate other case
specifically, check for conflicts both when mouse bindings are set and when the selection-override-modifiers setting itself is set
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 38 |
1 files changed, 31 insertions, 7 deletions
@@ -1349,13 +1349,6 @@ parse_section_mouse(struct context *ctx) else if (strcmp(key, "alternate-scroll-mode") == 0) return value_to_bool(ctx, &conf->mouse.alternate_scroll_mode); - else if (strcmp(key, "selection-override-modifiers") == 0) { - if (!parse_modifiers(ctx, ctx->value, strlen(ctx->value), &conf->mouse.selection_override_modifiers)) { - LOG_CONTEXTUAL_ERR("%s: invalid modifiers '%s'", key, ctx->value); - return false; - } - } - else { LOG_CONTEXTUAL_ERR("not a valid option: %s", key); return false; @@ -2166,6 +2159,37 @@ parse_section_mouse_bindings(struct context *ctx) const char *key = ctx->key; const char *value = ctx->value; + if (strcmp(ctx->key, "selection-override-modifiers") == 0) { + if (!parse_modifiers(ctx, ctx->value, strlen(ctx->value), + &conf->mouse.selection_override_modifiers)) { + LOG_CONTEXTUAL_ERR("%s: invalid modifiers '%s'", key, ctx->value); + return false; + } + + /* Ensure no existing bindings use these modifiers */ + for (size_t i = 0; i < conf->bindings.mouse.count; i++) { + const struct config_mouse_binding *binding = &conf->bindings.mouse.arr[i]; + struct key_combo combo = { + .modifiers = binding->modifiers, + .m = { + .button = binding->button, + .count = binding->count, + }, + }; + + struct key_combo_list key_combos = { + .count = 1, + .combos = &combo, + }; + + if (selection_override_interferes_with_mouse_binding(ctx, &key_combos)) { + return false; + } + } + + return true; + } + struct argv pipe_argv; ssize_t pipe_remove_len = pipe_argv_from_value(ctx, &pipe_argv); |
