[st] mouseshortcuts: fix custom modifier on release (4c84ac4)

This commit is contained in:
bakkeby 2020-04-02 16:23:53 +02:00
parent d230df0802
commit 914cee019d
1 changed files with 18 additions and 4 deletions

22
x.c
View File

@ -198,6 +198,7 @@ static void kpress(XEvent *);
static void cmessage(XEvent *); static void cmessage(XEvent *);
static void resize(XEvent *); static void resize(XEvent *);
static void focus(XEvent *); static void focus(XEvent *);
static uint buttonmask(uint);
static void brelease(XEvent *); static void brelease(XEvent *);
static void bpress(XEvent *); static void bpress(XEvent *);
static void bmotion(XEvent *); static void bmotion(XEvent *);
@ -396,19 +397,32 @@ evrow(XEvent *e)
return y / win.ch; return y / win.ch;
} }
uint
buttonmask(uint button)
{
return button == Button1 ? Button1Mask
: button == Button2 ? Button2Mask
: button == Button3 ? Button3Mask
: button == Button4 ? Button4Mask
: button == Button5 ? Button5Mask
: 0;
}
int int
mouseaction(XEvent *e, uint release) mouseaction(XEvent *e, uint release)
{ {
MouseShortcut *ms; MouseShortcut *ms;
/* ignore Button<N>mask for Button<N> - it's set on release */
uint state = e->xbutton.state & ~buttonmask(e->xbutton.button);
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH #if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
if (tisaltscr()) if (tisaltscr())
for (ms = maltshortcuts; ms < maltshortcuts + LEN(maltshortcuts); ms++) { for (ms = maltshortcuts; ms < maltshortcuts + LEN(maltshortcuts); ms++) {
if (ms->release == release && if (ms->release == release &&
ms->button == e->xbutton.button && ms->button == e->xbutton.button &&
(match(ms->mod, e->xbutton.state) || /* exact or forced */ (match(ms->mod, state) || /* exact or forced */
match(ms->mod, e->xbutton.state & ~forcemousemod))) { match(ms->mod, state & ~forcemousemod))) {
ms->func(&(ms->arg)); ms->func(&(ms->arg));
return 1; return 1;
} }
@ -418,8 +432,8 @@ mouseaction(XEvent *e, uint release)
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
if (ms->release == release && if (ms->release == release &&
ms->button == e->xbutton.button && ms->button == e->xbutton.button &&
(match(ms->mod, e->xbutton.state) || /* exact or forced */ (match(ms->mod, state) || /* exact or forced */
match(ms->mod, e->xbutton.state & ~forcemousemod))) { match(ms->mod, state & ~forcemousemod))) {
ms->func(&(ms->arg)); ms->func(&(ms->arg));
return 1; return 1;
} }