tapplied Brandon MacDone's static initialization patch for seltags and Client->… | |
git clone git://src.adamsgaard.dk/dwm | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit eeea4ef583a2ca3746e987bd2ecd570fd1869c2d | |
parent 883e09b2eb8b6a42289bc5a64294df4122d90e38 | |
Author: Anselm R. Garbe <[email protected]> | |
Date: Sat, 6 Oct 2007 19:43:15 +0200 | |
applied Brandon MacDone's static initialization patch for seltags and Client->t… | |
Diffstat: | |
M dwm.c | 44 +++++++++++++++--------------… | |
1 file changed, 21 insertions(+), 23 deletions(-) | |
--- | |
diff --git a/dwm.c b/dwm.c | |
t@@ -57,21 +57,6 @@ enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* … | |
/* typedefs */ | |
typedef struct Client Client; | |
-struct Client { | |
- char name[256]; | |
- int x, y, w, h; | |
- int rx, ry, rw, rh; /* revert geometry */ | |
- int basew, baseh, incw, inch, maxw, maxh, minw, minh; | |
- int minax, maxax, minay, maxay; | |
- long flags; | |
- unsigned int border, oldborder; | |
- Bool isbanned, isfixed, ismax, isfloating, wasfloating; | |
- Bool *tags; | |
- Client *next; | |
- Client *prev; | |
- Client *snext; | |
- Window win; | |
-}; | |
typedef struct { | |
int x, y, w, h; | |
t@@ -195,7 +180,7 @@ char stext[256]; | |
double mwfact; | |
int screen, sx, sy, sw, sh, wax, way, waw, wah; | |
int (*xerrorxlib)(Display *, XErrorEvent *); | |
-unsigned int bh, bpos, ntags; | |
+unsigned int bh, bpos; | |
unsigned int blw = 0; | |
unsigned int ltidx = 0; /* default */ | |
unsigned int nlayouts = 0; | |
t@@ -218,7 +203,6 @@ void (*handler[LASTEvent]) (XEvent *) = { | |
Atom wmatom[WMLast], netatom[NetLast]; | |
Bool otherwm, readin; | |
Bool running = True; | |
-Bool *seltags; | |
Bool selscreen = True; | |
Client *clients = NULL; | |
Client *sel = NULL; | |
t@@ -232,6 +216,26 @@ Regs *regs = NULL; | |
/* configuration, allows nested code to access above variables */ | |
#include "config.h" | |
+/* Statically define the number of tags. */ | |
+unsigned int ntags = sizeof tags / sizeof tags[0]; | |
+Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True}; | |
+ | |
+struct Client { | |
+ char name[256]; | |
+ int x, y, w, h; | |
+ int rx, ry, rw, rh; /* revert geometry */ | |
+ int basew, baseh, incw, inch, maxw, maxh, minw, minh; | |
+ int minax, maxax, minay, maxay; | |
+ long flags; | |
+ unsigned int border, oldborder; | |
+ Bool isbanned, isfixed, ismax, isfloating, wasfloating; | |
+ Bool tags[sizeof tags / sizeof tags[0]]; | |
+ Client *next; | |
+ Client *prev; | |
+ Client *snext; | |
+ Window win; | |
+}; | |
+ | |
/* functions*/ | |
void | |
applyrules(Client *c) { | |
t@@ -393,7 +397,6 @@ cleanup(void) { | |
XFreeCursor(dpy, cursor[CurMove]); | |
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); | |
XSync(dpy, False); | |
- free(seltags); | |
} | |
void | |
t@@ -1006,7 +1009,6 @@ manage(Window w, XWindowAttributes *wa) { | |
XWindowChanges wc; | |
c = emallocz(sizeof(Client)); | |
- c->tags = emallocz(ntags * sizeof(Bool)); | |
c->win = w; | |
c->x = wa->x; | |
c->y = wa->y; | |
t@@ -1467,9 +1469,6 @@ setup(void) { | |
/* init tags */ | |
compileregs(); | |
- ntags = sizeof tags / sizeof tags[0]; | |
- seltags = emallocz(sizeof(Bool) * ntags); | |
- seltags[0] = True; | |
/* init appearance */ | |
dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); | |
t@@ -1703,7 +1702,6 @@ unmanage(Client *c) { | |
focus(NULL); | |
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | |
setclientstate(c, WithdrawnState); | |
- free(c->tags); | |
free(c); | |
XSync(dpy, False); | |
XSetErrorHandler(xerror); |