aboutsummaryrefslogtreecommitdiffstats
path: root/x.c
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2019-10-24 15:42:07 +0300
committerHiltjo Posthuma <hiltjo@codemadness.org>2019-10-24 15:34:25 +0200
commita2c479c4c8d035c11a91e4b954a9f161bf4c7150 (patch)
tree2ec7bd03c60d9cd961ded572b4e5a6bff6f06c46 /x.c
parentd2b75db8d7519a20af8bf09e9c205507f9ff828c (diff)
downloadst-a2c479c4c8d035c11a91e4b954a9f161bf4c7150.tar.gz
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.
Diffstat (limited to 'x.c')
-rw-r--r--x.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/x.c b/x.c
index 8f570c2..6406925 100644
--- a/x.c
+++ b/x.c
@@ -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;
}
remember that computers suck.