applied Gottox' ClkTagBar patch
b86c8185
2 file(s) · +15 −24
| 84 | 84 | }; |
|
| 85 | 85 | ||
| 86 | 86 | /* button definitions */ |
|
| 87 | - | #define TAGBUTTONS(TAG) \ |
|
| 88 | - | { TAG, 0, Button1, view, {.ui = 1 << TAG} }, \ |
|
| 89 | - | { TAG, 0, Button3, toggleview, {.ui = 1 << TAG} }, \ |
|
| 90 | - | { TAG, MODKEY, Button1, tag, {.ui = 1 << TAG} }, \ |
|
| 91 | - | { TAG, MODKEY, Button3, toggletag, {.ui = 1 << TAG} }, |
|
| 92 | - | ||
| 93 | 87 | /* click can be a tag number (starting at 0), |
|
| 94 | 88 | * ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ |
|
| 95 | 89 | static Button buttons[] = { |
|
| 101 | 95 | { ClkClientWin, MODKEY, Button1, movemouse, {0} }, |
|
| 102 | 96 | { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, |
|
| 103 | 97 | { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, |
|
| 104 | - | TAGBUTTONS(0) |
|
| 105 | - | TAGBUTTONS(1) |
|
| 106 | - | TAGBUTTONS(2) |
|
| 107 | - | TAGBUTTONS(3) |
|
| 108 | - | TAGBUTTONS(4) |
|
| 109 | - | TAGBUTTONS(5) |
|
| 110 | - | TAGBUTTONS(6) |
|
| 111 | - | TAGBUTTONS(7) |
|
| 112 | - | TAGBUTTONS(8) |
|
| 98 | + | { ClkTagBar, 0, Button1, view, {0} }, \ |
|
| 99 | + | { ClkTagBar, 0, Button3, toggleview, {0} }, \ |
|
| 100 | + | { ClkTagBar, MODKEY, Button1, tag, {0} }, \ |
|
| 101 | + | { ClkTagBar, MODKEY, Button3, toggletag, {0} }, |
|
| 113 | 102 | }; |
|
| 114 | 103 | ||
| 60 | 60 | enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ |
|
| 61 | 61 | enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ |
|
| 62 | 62 | enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */ |
|
| 63 | - | enum { ClkLtSymbol = 64, ClkStatusText, ClkWinTitle, |
|
| 63 | + | enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, |
|
| 64 | 64 | ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ |
|
| 65 | 65 | ||
| 66 | 66 | /* typedefs */ |
|
| 304 | 304 | void |
|
| 305 | 305 | buttonpress(XEvent *e) { |
|
| 306 | 306 | uint i, x, click; |
|
| 307 | + | Arg arg = {0}; |
|
| 307 | 308 | Client *c; |
|
| 308 | 309 | XButtonPressedEvent *ev = &e->xbutton; |
|
| 309 | 310 | ||
| 310 | 311 | click = ClkRootWin; |
|
| 311 | 312 | if(ev->window == barwin) { |
|
| 312 | - | i = x = 0; |
|
| 313 | - | do |
|
| 313 | + | for(i = x = 0; ev->x >= x && ++i < LENGTH(tags); i++) |
|
| 314 | 314 | x += TEXTW(tags[i]); |
|
| 315 | - | while(ev->x >= x && ++i < LENGTH(tags)); |
|
| 316 | - | if(i < LENGTH(tags)) |
|
| 317 | - | click = i; |
|
| 315 | + | if(i < LENGTH(tags)) { |
|
| 316 | + | click = ClkTagBar; |
|
| 317 | + | arg.ui = 1 << i; |
|
| 318 | + | } |
|
| 318 | 319 | else if(ev->x < x + blw) |
|
| 319 | 320 | click = ClkLtSymbol; |
|
| 320 | 321 | else if(ev->x > wx + ww - TEXTW(stext)) |
|
| 330 | 331 | for(i = 0; i < LENGTH(buttons); i++) |
|
| 331 | 332 | if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button |
|
| 332 | 333 | && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) |
|
| 333 | - | buttons[i].func(&buttons[i].arg); |
|
| 334 | + | buttons[i].func(click == ClkTagBar ? &arg : &buttons[i].arg); |
|
| 334 | 335 | } |
|
| 335 | 336 | ||
| 336 | 337 | void |
|
| 1295 | 1296 | ||
| 1296 | 1297 | void |
|
| 1297 | 1298 | setlayout(const Arg *arg) { |
|
| 1298 | - | sellt ^= 1; |
|
| 1299 | - | if(arg && arg->v && arg->v != lt[sellt]) |
|
| 1299 | + | if(!arg || !arg->v || arg->v != lt[sellt]) |
|
| 1300 | + | sellt ^= 1; |
|
| 1301 | + | if(arg && arg->v) |
|
| 1300 | 1302 | lt[sellt] = (Layout *)arg->v; |
|
| 1301 | 1303 | if(sel) |
|
| 1302 | 1304 | arrange(); |
|