[ARCHIVED] my build of st
git clone git://git.ckyln.com/~cem/old-st.git
Log | Files | Refs | README | LICENSE

commit b1905e8519476371c494051db0e697fcf07514a6
parent ab7c232ecb4f943bc0e63d0955a2979fccbd13d3
Author: Avi Halachmi (:avih) <avihpit@yahoo.com>
Date:   Thu, 24 Oct 2019 15:42:07 +0300

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.

Mx.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/x.c b/x.c @@ -442,7 +442,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; }