From fade19b51209fa130bc6f9513307c9614721a0fb Mon Sep 17 00:00:00 2001 From: "feeptr@codeberg.org" Date: Mon, 27 Sep 2021 19:39:39 +0000 Subject: doc: document select-override-mods --- doc/foot.ini.5.scd | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 1b6c4d8c..f84cc9f6 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -470,6 +470,16 @@ applications can change these at runtime. Default: _yes_. +*selection-override-modifiers* + Modifiers. The set of modifiers which, when held, will override + attempts by programs running in the terminal to capture mouse + input. + + Any modifiers in this set cannot be used for mouse bindings + themselves. + + Default: Shift + # SECTION: colors @@ -865,9 +875,10 @@ of the modifiers *must* be valid XKB key names, and the button name *must* be a valid libinput name. You can find the button names using *libinput debug-events*. -Note that *Shift* cannot be used as a modifier in mouse bindings since -it is used to enable selection when the client application is grabbing -the mouse. +Note that the modifiers set in *mouse.selection-override-modifiers* +(by default, *Shift*) cannot be used as modifiers in mouse bindings +since they are used to enable selection when the client application is +grabbing the mouse. The trailing *COUNT* is optional and specifies the click count required to trigger the binding. The default if *COUNT* is omitted is -- cgit v1.3 From b52cd67467cb5e5f334f00680b42f8e071be1e79 Mon Sep 17 00:00:00 2001 From: "feeptr@codeberg.org" Date: Mon, 29 Nov 2021 22:06:35 +0000 Subject: 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 --- CHANGELOG.md | 6 +++--- config.c | 38 +++++++++++++++++++++++++++++++------- doc/foot.ini.5.scd | 20 ++++++-------------- foot.ini | 2 +- 4 files changed, 41 insertions(+), 25 deletions(-) (limited to 'doc') diff --git a/CHANGELOG.md b/CHANGELOG.md index cc9c864b..23f10509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,9 +38,9 @@ ## Unreleased ### Added -* `[mouse].selection-override-modifiers` option, specifying which modifiers - to hold to override mouse grabs by client applications and force selection - instead. +* `[mouse-bindings].selection-override-modifiers` option, specifying + which modifiers to hold to override mouse grabs by client + applications and force selection instead. ### Changed diff --git a/config.c b/config.c index d4eac3ac..59d7bdab 100644 --- a/config.c +++ b/config.c @@ -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); diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index f84cc9f6..5f55dc45 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -470,16 +470,6 @@ applications can change these at runtime. Default: _yes_. -*selection-override-modifiers* - Modifiers. The set of modifiers which, when held, will override - attempts by programs running in the terminal to capture mouse - input. - - Any modifiers in this set cannot be used for mouse bindings - themselves. - - Default: Shift - # SECTION: colors @@ -875,10 +865,12 @@ of the modifiers *must* be valid XKB key names, and the button name *must* be a valid libinput name. You can find the button names using *libinput debug-events*. -Note that the modifiers set in *mouse.selection-override-modifiers* -(by default, *Shift*) cannot be used as modifiers in mouse bindings -since they are used to enable selection when the client application is -grabbing the mouse. +The modifiers set in *[mouse-bindings].selection-override-modifiers* +(by default, *Shift*) cannot be used as modifiers in mouse bindings, +and are instead used to enable selecting text with the mouse +irrespective of whether a client application currently has the mouse +grabbed. Because the order of bindings is significant, it's best to +set this prior to any other mouse bindings that might use *Shift*. The trailing *COUNT* is optional and specifies the click count required to trigger the binding. The default if *COUNT* is omitted is diff --git a/foot.ini b/foot.ini index d756a7e4..399becaa 100644 --- a/foot.ini +++ b/foot.ini @@ -63,7 +63,6 @@ [mouse] # hide-when-typing=no # alternate-scroll-mode=yes -# selection-override-modifiers=Shift [colors] # alpha=1.0 @@ -170,6 +169,7 @@ # toggle-url-visible=t [mouse-bindings] +# selection-override-modifiers=Shift # primary-paste=BTN_MIDDLE # select-begin=BTN_LEFT # select-begin-block=Control+BTN_LEFT -- cgit v1.3 From a6c543a32c51226282e90f47ae9ac13f37430009 Mon Sep 17 00:00:00 2001 From: "feeptr@codeberg.org" Date: Sat, 4 Dec 2021 16:22:33 +0000 Subject: improve documentation for [mouse-bindings].selection-override-modifiers --- doc/foot.ini.5.scd | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'doc') diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 5f55dc45..e1922634 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -865,13 +865,6 @@ of the modifiers *must* be valid XKB key names, and the button name *must* be a valid libinput name. You can find the button names using *libinput debug-events*. -The modifiers set in *[mouse-bindings].selection-override-modifiers* -(by default, *Shift*) cannot be used as modifiers in mouse bindings, -and are instead used to enable selecting text with the mouse -irrespective of whether a client application currently has the mouse -grabbed. Because the order of bindings is significant, it's best to -set this prior to any other mouse bindings that might use *Shift*. - The trailing *COUNT* is optional and specifies the click count required to trigger the binding. The default if *COUNT* is omitted is _1_. @@ -882,7 +875,19 @@ say you want to bind *BTN\_MIDDLE* to *fullscreen*. Since need to unmap the default binding. This can be done by setting _action=none_; e.g. *primary-paste=none*. -All actions listed under *key-bindings* can be used here as well. +*selection-override-modifiers* + The modifiers set in this set (which may be set to any combination + of modifiers, e.g. _mod1+mod2+mod3_, as well as _none_) are used + to enable selecting text with the mouse irrespective of whether a + client application currently has the mouse grabbed. + These modifiers cannot be used as modifiers in mouse bindings. + Because the order of bindings is significant, it is best to set + this prior to any other mouse bindings that might use modifiers in + the default set. + Default: _Shift_ + +The actions to which mouse combos can be bound are listed below. All +actions listed under *key-bindings* can be used here as well. *select-begin* Begin an interactive selection. The selection is finalized, and -- cgit v1.3