diff options
| author | CismonX <admin@cismon.net> | 2026-08-30 23:41:35 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2026-09-02 05:51:03 +0000 |
| commit | 1c4cfc2dfce5698411a552f056535f9a2fb2a6f6 (patch) | |
| tree | ed07e3290edf4252e81ebe5abe7f6135199d8f44 | |
| parent | config: fix error message for modifiers conflict (diff) | |
config: fix modifiers conflict check
Currently, if a mouse binding contains _any_ modifier key set in
config 'selection-override-modifiers', it does not work since
these modifiers get unset in function 'match_mouse_binding()'.
Function 'resolve_key_binding_collisions()' is supposed to detect
this and display an error message, however, it does not work unless
the conflicting modifiers are identical.
For example, given the following config options:
selection-override-modifiers=Control+Shift
select-begin-block=Control+BTN_LEFT
Foot does not display an error message for this, but if you try to
select text with 'Control+BTN_LEFT', it behaves as if only 'BTN_LEFT'
is pressed.
This is due to function 'modifiers_disjoint()' being implemented as
"not equal" rather than "disjoint".
Fixed by properly implementing this function. Also clarify the
'selection-override-modifiers' config option in the man page.
As a side effect, this also fixes 'selection-override-modifiers=none'
conflicting with mouse bindings that do not contain modifier keys
(an empty set is disjoint with itself).
| -rw-r--r-- | config.c | 20 | ||||
| -rw-r--r-- | doc/foot.ini.5.scd | 2 |
2 files changed, 20 insertions, 2 deletions
@@ -2230,7 +2230,25 @@ static bool modifiers_disjoint(const config_modifier_list_t *mods1, const config_modifier_list_t *mods2) { - return !modifiers_equal(mods1, mods2); + size_t count = 0; + tll_foreach(*mods1, it1) { + size_t skip = count; + tll_foreach(*mods2, it2) { + if (skip > 0) { + --skip; + continue; + } + + int r = strcmp(it1->item, it2->item); + if (r == 0) + return false; + if (r < 0) + break; + + ++count; + } + } + return true; } static char * NOINLINE diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index c7fe22c7..8bedf451 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -1738,7 +1738,7 @@ _action=none_; e.g. *primary-paste=none*. 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. + Any combination of these modifiers cannot be used 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. |
