X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=x.c;h=e5f1737a3ee35105e68121ac1871fee2a75117d5;hb=e997303502ddd5c26cfc41af0ff5356bffc04359;hp=1f621293a7a2ebd2b032d43c5598ef5b6f9e0e97;hpb=26cdfebf31f024e331429e482b1ee342708888e3;p=st.git diff --git a/x.c b/x.c index 1f62129..e5f1737 100644 --- a/x.c +++ b/x.c @@ -15,7 +15,7 @@ #include #include -static char *argv0; +char *argv0; #include "arg.h" #include "st.h" #include "win.h" @@ -171,6 +171,7 @@ static void kpress(XEvent *); static void cmessage(XEvent *); static void resize(XEvent *); static void focus(XEvent *); +static uint buttonmask(uint); static int mouseaction(XEvent *, uint); static void brelease(XEvent *); static void bpress(XEvent *); @@ -423,16 +424,30 @@ mousereport(XEvent *e) ttywrite(buf, len, 0); } +uint +buttonmask(uint button) +{ + return button == Button1 ? Button1Mask + : button == Button2 ? Button2Mask + : button == Button3 ? Button3Mask + : button == Button4 ? Button4Mask + : button == Button5 ? Button5Mask + : 0; +} + int mouseaction(XEvent *e, uint release) { MouseShortcut *ms; + /* ignore Buttonmask for Button - it's set on release */ + uint state = e->xbutton.state & ~buttonmask(e->xbutton.button); + for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { if (ms->release == release && ms->button == e->xbutton.button && - (match(ms->mod, e->xbutton.state) || /* exact or forced */ - match(ms->mod, e->xbutton.state & ~forcemousemod))) { + (match(ms->mod, state) || /* exact or forced */ + match(ms->mod, state & ~forcemousemod))) { ms->func(&(ms->arg)); return 1; } @@ -1047,7 +1062,6 @@ ximopen(Display *dpy) xw.ime.xic = XCreateIC(xw.ime.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, xw.win, - XNFocusWindow, xw.win, XNDestroyCallback, &icdestroy, NULL); }