diff options
Diffstat (limited to 'x.c')
| -rw-r--r-- | x.c | 19 |
1 files changed, 17 insertions, 2 deletions
| @@ -171,6 +171,7 @@ static void kpress(XEvent *); | |||
| 171 | static void cmessage(XEvent *); | 171 | static void cmessage(XEvent *); |
| 172 | static void resize(XEvent *); | 172 | static void resize(XEvent *); |
| 173 | static void focus(XEvent *); | 173 | static void focus(XEvent *); |
| 174 | static uint buttonmask(uint); | ||
| 174 | static int mouseaction(XEvent *, uint); | 175 | static int mouseaction(XEvent *, uint); |
| 175 | static void brelease(XEvent *); | 176 | static void brelease(XEvent *); |
| 176 | static void bpress(XEvent *); | 177 | static void bpress(XEvent *); |
| @@ -423,16 +424,30 @@ mousereport(XEvent *e) | |||
| 423 | ttywrite(buf, len, 0); | 424 | ttywrite(buf, len, 0); |
| 424 | } | 425 | } |
| 425 | 426 | ||
| 427 | uint | ||
| 428 | buttonmask(uint button) | ||
| 429 | { | ||
| 430 | return button == Button1 ? Button1Mask | ||
| 431 | : button == Button2 ? Button2Mask | ||
| 432 | : button == Button3 ? Button3Mask | ||
| 433 | : button == Button4 ? Button4Mask | ||
| 434 | : button == Button5 ? Button5Mask | ||
| 435 | : 0; | ||
| 436 | } | ||
| 437 | |||
| 426 | int | 438 | int |
| 427 | mouseaction(XEvent *e, uint release) | 439 | mouseaction(XEvent *e, uint release) |
| 428 | { | 440 | { |
| 429 | MouseShortcut *ms; | 441 | MouseShortcut *ms; |
| 430 | 442 | ||
| 443 | /* ignore Button<N>mask for Button<N> - it's set on release */ | ||
| 444 | uint state = e->xbutton.state & ~buttonmask(e->xbutton.button); | ||
| 445 | |||
| 431 | for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { | 446 | for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { |
| 432 | if (ms->release == release && | 447 | if (ms->release == release && |
| 433 | ms->button == e->xbutton.button && | 448 | ms->button == e->xbutton.button && |
| 434 | (match(ms->mod, e->xbutton.state) || /* exact or forced */ | 449 | (match(ms->mod, state) || /* exact or forced */ |
| 435 | match(ms->mod, e->xbutton.state & ~forcemousemod))) { | 450 | match(ms->mod, state & ~forcemousemod))) { |
| 436 | ms->func(&(ms->arg)); | 451 | ms->func(&(ms->arg)); |
| 437 | return 1; | 452 | return 1; |
| 438 | } | 453 | } |
