applied Brandon MacDone's static initialization patch for seltags and Client->tags
eeea4ef5
1 file(s) · +21 −23
| 57 | 57 | ||
| 58 | 58 | /* typedefs */ |
|
| 59 | 59 | typedef struct Client Client; |
|
| 60 | - | struct Client { |
|
| 61 | - | char name[256]; |
|
| 62 | - | int x, y, w, h; |
|
| 63 | - | int rx, ry, rw, rh; /* revert geometry */ |
|
| 64 | - | int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
|
| 65 | - | int minax, maxax, minay, maxay; |
|
| 66 | - | long flags; |
|
| 67 | - | unsigned int border, oldborder; |
|
| 68 | - | Bool isbanned, isfixed, ismax, isfloating, wasfloating; |
|
| 69 | - | Bool *tags; |
|
| 70 | - | Client *next; |
|
| 71 | - | Client *prev; |
|
| 72 | - | Client *snext; |
|
| 73 | - | Window win; |
|
| 74 | - | }; |
|
| 75 | 60 | ||
| 76 | 61 | typedef struct { |
|
| 77 | 62 | int x, y, w, h; |
|
| 195 | 180 | double mwfact; |
|
| 196 | 181 | int screen, sx, sy, sw, sh, wax, way, waw, wah; |
|
| 197 | 182 | int (*xerrorxlib)(Display *, XErrorEvent *); |
|
| 198 | - | unsigned int bh, bpos, ntags; |
|
| 183 | + | unsigned int bh, bpos; |
|
| 199 | 184 | unsigned int blw = 0; |
|
| 200 | 185 | unsigned int ltidx = 0; /* default */ |
|
| 201 | 186 | unsigned int nlayouts = 0; |
|
| 218 | 203 | Atom wmatom[WMLast], netatom[NetLast]; |
|
| 219 | 204 | Bool otherwm, readin; |
|
| 220 | 205 | Bool running = True; |
|
| 221 | - | Bool *seltags; |
|
| 222 | 206 | Bool selscreen = True; |
|
| 223 | 207 | Client *clients = NULL; |
|
| 224 | 208 | Client *sel = NULL; |
|
| 232 | 216 | /* configuration, allows nested code to access above variables */ |
|
| 233 | 217 | #include "config.h" |
|
| 234 | 218 | ||
| 219 | + | /* Statically define the number of tags. */ |
|
| 220 | + | unsigned int ntags = sizeof tags / sizeof tags[0]; |
|
| 221 | + | Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True}; |
|
| 222 | + | ||
| 223 | + | struct Client { |
|
| 224 | + | char name[256]; |
|
| 225 | + | int x, y, w, h; |
|
| 226 | + | int rx, ry, rw, rh; /* revert geometry */ |
|
| 227 | + | int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
|
| 228 | + | int minax, maxax, minay, maxay; |
|
| 229 | + | long flags; |
|
| 230 | + | unsigned int border, oldborder; |
|
| 231 | + | Bool isbanned, isfixed, ismax, isfloating, wasfloating; |
|
| 232 | + | Bool tags[sizeof tags / sizeof tags[0]]; |
|
| 233 | + | Client *next; |
|
| 234 | + | Client *prev; |
|
| 235 | + | Client *snext; |
|
| 236 | + | Window win; |
|
| 237 | + | }; |
|
| 238 | + | ||
| 235 | 239 | /* functions*/ |
|
| 236 | 240 | void |
|
| 237 | 241 | applyrules(Client *c) { |
|
| 393 | 397 | XFreeCursor(dpy, cursor[CurMove]); |
|
| 394 | 398 | XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); |
|
| 395 | 399 | XSync(dpy, False); |
|
| 396 | - | free(seltags); |
|
| 397 | 400 | } |
|
| 398 | 401 | ||
| 399 | 402 | void |
|
| 1006 | 1009 | XWindowChanges wc; |
|
| 1007 | 1010 | ||
| 1008 | 1011 | c = emallocz(sizeof(Client)); |
|
| 1009 | - | c->tags = emallocz(ntags * sizeof(Bool)); |
|
| 1010 | 1012 | c->win = w; |
|
| 1011 | 1013 | c->x = wa->x; |
|
| 1012 | 1014 | c->y = wa->y; |
|
| 1467 | 1469 | ||
| 1468 | 1470 | /* init tags */ |
|
| 1469 | 1471 | compileregs(); |
|
| 1470 | - | ntags = sizeof tags / sizeof tags[0]; |
|
| 1471 | - | seltags = emallocz(sizeof(Bool) * ntags); |
|
| 1472 | - | seltags[0] = True; |
|
| 1473 | 1472 | ||
| 1474 | 1473 | /* init appearance */ |
|
| 1475 | 1474 | dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); |
|
| 1703 | 1702 | focus(NULL); |
|
| 1704 | 1703 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 1705 | 1704 | setclientstate(c, WithdrawnState); |
|
| 1706 | - | free(c->tags); |
|
| 1707 | 1705 | free(c); |
|
| 1708 | 1706 | XSync(dpy, False); |
|
| 1709 | 1707 | XSetErrorHandler(xerror); |
|