[hackers] [st] mouse shortcuts: allow using forcemousemod (e.g. shift) || Avi Halachmi (:avih)
commit a2c479c4c8d035c11a91e4b954a9f161bf4c7150
Author: Avi Halachmi (:avih) <avihpit_AT_yahoo.com>
AuthorDate: Thu Oct 24 15:42:07 2019 +0300
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Thu Oct 24 15:34:25 2019 +0200
mouse shortcuts: allow using forcemousemod (e.g. shift)
The recent mouse shurtcuts commits allow customization, but ignore
forcemousemod mask (default: shift) as a modifier, for no good reason
other than following the behavior of the KB shortcuts.
Allow using forcemousemod too, which now can be used to invoke
different shortcuts, though the automatic effect of forcemousemod will
be lost for buttons which use mask with forcemousemod.
E.g. the default is:
static uint forcemousemod = ShiftMask;
...
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
...
where ttysend will be invoked for button4 with any mod when not in mouse
mode, and with shift when in mouse mode.
Now it's possible to do this:
{ ShiftMask, Button4, ttysend, {.s = "foo"} },
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
Which will invoke ttysend("foo") while shift is held and ttysend("\031")
otherwise. Shift still overrides mouse mode, but will now send "foo".
Previously with this setup the second binding was always invoked
because the forceousemod mask was always removed from the event.
Buttons which don't use forcemousemod behave the same as before.
This is useful e.g. for the scrollback mouse patch, which wants to
configure shift+wheel for scrollback, while keeping the normal behavior
without shift.
diff --git a/x.c b/x.c
index 8f570c2..6406925 100644
--- a/x.c
+++ b/x.c
_AT_@ -426,7 +426,8 @@ mouseaction(XEvent *e, uint release)
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
if (ms->release == release &&
ms->button == e->xbutton.button &&
- match(ms->mod, e->xbutton.state & ~forcemousemod)) {
+ (match(ms->mod, e->xbutton.state) || /* exact or forced */
+ match(ms->mod, e->xbutton.state & ~forcemousemod))) {
ms->func(&(ms->arg));
return 1;
}
Received on Thu Oct 24 2019 - 15:35:22 CEST
This archive was generated by hypermail 2.3.0
: Thu Oct 24 2019 - 15:36:26 CEST