applied Gottox bitmask + void *arg patch 39d1ecd5
Anselm R Garbe · 2008-05-22 11:04 3 file(s) · +138 −168
config.def.h +44 −43
18 18
19 19
Rule rules[] = {
20 20
	/* class      instance    title       tags ref      isfloating */
21 -
	{ "Gimp",     NULL,       NULL,       NULL,         True },
21 +
	{ "Gimp",     NULL,       NULL,       0,            True },
22 +
	{ "Firefox",  NULL,       NULL,       1 << 8,       True },
22 23
};
23 24
24 25
/* layout(s) */
35 36
#define MODKEY Mod1Mask
36 37
Key keys[] = {
37 38
	/* modifier                     key        function        argument */
38 -
	{ MODKEY,                       XK_p,      spawn,          "exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
39 -
	{ MODKEY|ShiftMask,             XK_Return, spawn,          "exec uxterm" },
39 +
	{ MODKEY,                       XK_p,      spawn,          (char *)"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
40 +
	{ MODKEY|ShiftMask,             XK_Return, spawn,          (char *)"exec uxterm" },
40 41
	{ MODKEY,                       XK_b,      togglebar,      NULL },
41 42
	{ MODKEY,                       XK_j,      focusnext,      NULL },
42 43
	{ MODKEY,                       XK_k,      focusprev,      NULL },
43 -
	{ MODKEY,                       XK_h,      setmfact,       "-0.05" },
44 -
	{ MODKEY,                       XK_l,      setmfact,       "+0.05" },
44 +
	{ MODKEY,                       XK_h,      setmfact,       (double[]){+0.05} },
45 +
	{ MODKEY,                       XK_l,      setmfact,       (double[]){-0.05} },
45 46
	{ MODKEY,                       XK_Return, zoom,           NULL },
46 47
	{ MODKEY,                       XK_Tab,    viewprevtag,    NULL },
47 48
	{ MODKEY|ShiftMask,             XK_c,      killclient,     NULL },
48 49
	{ MODKEY,                       XK_space,  togglelayout,   NULL },
49 50
	{ MODKEY|ShiftMask,             XK_space,  togglefloating, NULL },
50 -
	{ MODKEY,                       XK_0,      view,           NULL },
51 -
	{ MODKEY,                       XK_1,      view,           tags[0] },
52 -
	{ MODKEY,                       XK_2,      view,           tags[1] },
53 -
	{ MODKEY,                       XK_3,      view,           tags[2] },
54 -
	{ MODKEY,                       XK_4,      view,           tags[3] },
55 -
	{ MODKEY,                       XK_5,      view,           tags[4] },
56 -
	{ MODKEY,                       XK_6,      view,           tags[5] },
57 -
	{ MODKEY,                       XK_7,      view,           tags[6] },
58 -
	{ MODKEY,                       XK_8,      view,           tags[7] },
59 -
	{ MODKEY,                       XK_9,      view,           tags[8] },
60 -
	{ MODKEY|ControlMask,           XK_1,      toggleview,     tags[0] },
61 -
	{ MODKEY|ControlMask,           XK_2,      toggleview,     tags[1] },
62 -
	{ MODKEY|ControlMask,           XK_3,      toggleview,     tags[2] },
63 -
	{ MODKEY|ControlMask,           XK_4,      toggleview,     tags[3] },
64 -
	{ MODKEY|ControlMask,           XK_5,      toggleview,     tags[4] },
65 -
	{ MODKEY|ControlMask,           XK_6,      toggleview,     tags[5] },
66 -
	{ MODKEY|ControlMask,           XK_7,      toggleview,     tags[6] },
67 -
	{ MODKEY|ControlMask,           XK_8,      toggleview,     tags[7] },
68 -
	{ MODKEY|ControlMask,           XK_9,      toggleview,     tags[8] },
69 -
	{ MODKEY|ShiftMask,             XK_0,      tag,            NULL },
70 -
	{ MODKEY|ShiftMask,             XK_1,      tag,            tags[0] },
71 -
	{ MODKEY|ShiftMask,             XK_2,      tag,            tags[1] },
72 -
	{ MODKEY|ShiftMask,             XK_3,      tag,            tags[2] },
73 -
	{ MODKEY|ShiftMask,             XK_4,      tag,            tags[3] },
74 -
	{ MODKEY|ShiftMask,             XK_5,      tag,            tags[4] },
75 -
	{ MODKEY|ShiftMask,             XK_6,      tag,            tags[5] },
76 -
	{ MODKEY|ShiftMask,             XK_7,      tag,            tags[6] },
77 -
	{ MODKEY|ShiftMask,             XK_8,      tag,            tags[7] },
78 -
	{ MODKEY|ShiftMask,             XK_9,      tag,            tags[8] },
79 -
	{ MODKEY|ControlMask|ShiftMask, XK_1,      toggletag,      tags[0] },
80 -
	{ MODKEY|ControlMask|ShiftMask, XK_2,      toggletag,      tags[1] },
81 -
	{ MODKEY|ControlMask|ShiftMask, XK_3,      toggletag,      tags[2] },
82 -
	{ MODKEY|ControlMask|ShiftMask, XK_4,      toggletag,      tags[3] },
83 -
	{ MODKEY|ControlMask|ShiftMask, XK_5,      toggletag,      tags[4] },
84 -
	{ MODKEY|ControlMask|ShiftMask, XK_6,      toggletag,      tags[5] },
85 -
	{ MODKEY|ControlMask|ShiftMask, XK_7,      toggletag,      tags[6] },
86 -
	{ MODKEY|ControlMask|ShiftMask, XK_8,      toggletag,      tags[7] },
87 -
	{ MODKEY|ControlMask|ShiftMask, XK_9,      toggletag,      tags[8] },
51 +
	{ MODKEY,                       XK_0,      view,           (int[]){ ~0 } },
52 +
	{ MODKEY,                       XK_1,      view,           (int[]){ 1 << 0 } },
53 +
	{ MODKEY,                       XK_2,      view,           (int[]){ 1 << 1 } },
54 +
	{ MODKEY,                       XK_3,      view,           (int[]){ 1 << 2 } },
55 +
	{ MODKEY,                       XK_4,      view,           (int[]){ 1 << 3 } },
56 +
	{ MODKEY,                       XK_5,      view,           (int[]){ 1 << 4 } },
57 +
	{ MODKEY,                       XK_6,      view,           (int[]){ 1 << 5 } },
58 +
	{ MODKEY,                       XK_7,      view,           (int[]){ 1 << 6 } },
59 +
	{ MODKEY,                       XK_8,      view,           (int[]){ 1 << 7 } },
60 +
	{ MODKEY,                       XK_9,      view,           (int[]){ 1 << 8 } },
61 +
	{ MODKEY|ControlMask,           XK_1,      toggleview,     (int[]){ 1 << 0 } },
62 +
	{ MODKEY|ControlMask,           XK_2,      toggleview,     (int[]){ 1 << 1 } },
63 +
	{ MODKEY|ControlMask,           XK_3,      toggleview,     (int[]){ 1 << 2 } },
64 +
	{ MODKEY|ControlMask,           XK_4,      toggleview,     (int[]){ 1 << 3 } },
65 +
	{ MODKEY|ControlMask,           XK_5,      toggleview,     (int[]){ 1 << 4 } },
66 +
	{ MODKEY|ControlMask,           XK_6,      toggleview,     (int[]){ 1 << 5 } },
67 +
	{ MODKEY|ControlMask,           XK_7,      toggleview,     (int[]){ 1 << 6 } },
68 +
	{ MODKEY|ControlMask,           XK_8,      toggleview,     (int[]){ 1 << 7 } },
69 +
	{ MODKEY|ControlMask,           XK_9,      toggleview,     (int[]){ 1 << 8 } },
70 +
	{ MODKEY|ShiftMask,             XK_0,      tag,            (int[]){ ~0 } },
71 +
	{ MODKEY|ShiftMask,             XK_1,      tag,            (int[]){ 1 << 0 } },
72 +
	{ MODKEY|ShiftMask,             XK_2,      tag,            (int[]){ 1 << 1 } },
73 +
	{ MODKEY|ShiftMask,             XK_3,      tag,            (int[]){ 1 << 2 } },
74 +
	{ MODKEY|ShiftMask,             XK_4,      tag,            (int[]){ 1 << 3 } },
75 +
	{ MODKEY|ShiftMask,             XK_5,      tag,            (int[]){ 1 << 4 } },
76 +
	{ MODKEY|ShiftMask,             XK_6,      tag,            (int[]){ 1 << 5 } },
77 +
	{ MODKEY|ShiftMask,             XK_7,      tag,            (int[]){ 1 << 6 } },
78 +
	{ MODKEY|ShiftMask,             XK_8,      tag,            (int[]){ 1 << 7 } },
79 +
	{ MODKEY|ShiftMask,             XK_9,      tag,            (int[]){ 1 << 8 } },
80 +
	{ MODKEY|ControlMask|ShiftMask, XK_1,      toggletag,      (int[]){ 1 << 0 } },
81 +
	{ MODKEY|ControlMask|ShiftMask, XK_2,      toggletag,      (int[]){ 1 << 1 } },
82 +
	{ MODKEY|ControlMask|ShiftMask, XK_3,      toggletag,      (int[]){ 1 << 2 } },
83 +
	{ MODKEY|ControlMask|ShiftMask, XK_4,      toggletag,      (int[]){ 1 << 3 } },
84 +
	{ MODKEY|ControlMask|ShiftMask, XK_5,      toggletag,      (int[]){ 1 << 4 } },
85 +
	{ MODKEY|ControlMask|ShiftMask, XK_6,      toggletag,      (int[]){ 1 << 5 } },
86 +
	{ MODKEY|ControlMask|ShiftMask, XK_7,      toggletag,      (int[]){ 1 << 6 } },
87 +
	{ MODKEY|ControlMask|ShiftMask, XK_8,      toggletag,      (int[]){ 1 << 7 } },
88 +
	{ MODKEY|ControlMask|ShiftMask, XK_9,      toggletag,      (int[]){ 1 << 8 } },
88 89
	{ MODKEY|ShiftMask,             XK_q,      quit,           NULL },
89 90
};
config.mk +4 −4
20 20
21 21
# flags
22 22
CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
23 -
CFLAGS = -Os ${INCS} ${CPPFLAGS}
24 -
LDFLAGS = -s ${LIBS}
25 -
#CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} ${CPPFLAGS}
26 -
#LDFLAGS = -g ${LIBS}
23 +
#CFLAGS = -Os ${INCS} ${CPPFLAGS}
24 +
#LDFLAGS = -s ${LIBS}
25 +
CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} ${CPPFLAGS}
26 +
LDFLAGS = -g ${LIBS}
27 27
28 28
# Solaris
29 29
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
dwm.c +90 −121
51 51
#define LENGTH(x)       (sizeof x / sizeof x[0])
52 52
#define MAXTAGLEN       16
53 53
#define MOUSEMASK       (BUTTONMASK|PointerMotionMask)
54 +
#define TAGMASK         ((int)((1LL << LENGTH(tags)) - 1))
54 55
55 56
/* enums */
56 57
enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
68 69
	long flags;
69 70
	unsigned int bw, oldbw;
70 71
	Bool isbanned, isfixed, isfloating, isurgent;
71 -
	Bool *tags;
72 +
	unsigned int tags;
72 73
	Client *next;
73 74
	Client *prev;
74 75
	Client *snext;
93 94
typedef struct {
94 95
	unsigned long mod;
95 96
	KeySym keysym;
96 -
	void (*func)(const char *arg);
97 -
	const char *arg;
97 +
	void (*func)(void *arg);
98 +
	void *arg;
98 99
} Key;
99 100
100 101
typedef struct {
107 108
	const char *class;
108 109
	const char *instance;
109 110
	const char *title;
110 -
	const char *tag;
111 +
	unsigned int tags;
111 112
	Bool isfloating;
112 113
} Rule;
113 114
135 136
void expose(XEvent *e);
136 137
void focus(Client *c);
137 138
void focusin(XEvent *e);
138 -
void focusnext(const char *arg);
139 -
void focusprev(const char *arg);
139 +
void focusnext(void *arg);
140 +
void focusprev(void *arg);
140 141
Client *getclient(Window w);
141 142
unsigned long getcolor(const char *colstr);
142 143
long getstate(Window w);
143 144
Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
144 145
void grabbuttons(Client *c, Bool focused);
145 146
void grabkeys(void);
146 -
unsigned int idxoftag(const char *t);
147 147
void initfont(const char *fontstr);
148 148
Bool isoccupied(unsigned int t);
149 149
Bool isprotodel(Client *c);
150 150
Bool isurgent(unsigned int t);
151 151
Bool isvisible(Client *c);
152 152
void keypress(XEvent *e);
153 -
void killclient(const char *arg);
153 +
void killclient(void *arg);
154 154
void manage(Window w, XWindowAttributes *wa);
155 155
void mappingnotify(XEvent *e);
156 156
void maprequest(XEvent *e);
157 157
void movemouse(Client *c);
158 158
Client *nextunfloating(Client *c);
159 159
void propertynotify(XEvent *e);
160 -
void quit(const char *arg);
160 +
void quit(void *arg);
161 161
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
162 162
void resizemouse(Client *c);
163 163
void restack(void);
164 164
void run(void);
165 165
void scan(void);
166 166
void setclientstate(Client *c, long state);
167 -
void setmfact(const char *arg);
167 +
void setmfact(void *arg);
168 168
void setup(void);
169 -
void spawn(const char *arg);
170 -
void tag(const char *arg);
169 +
void spawn(void *arg);
170 +
void tag(void *arg);
171 171
unsigned int textnw(const char *text, unsigned int len);
172 172
unsigned int textw(const char *text);
173 173
void tile(void);
174 174
void tileresize(Client *c, int x, int y, int w, int h);
175 -
void togglebar(const char *arg);
176 -
void togglefloating(const char *arg);
177 -
void togglelayout(const char *arg);
178 -
void toggletag(const char *arg);
179 -
void toggleview(const char *arg);
175 +
void togglebar(void *arg);
176 +
void togglefloating(void *arg);
177 +
void togglelayout(void *arg);
178 +
void toggletag(void *arg);
179 +
void toggleview(void *arg);
180 180
void unban(Client *c);
181 181
void unmanage(Client *c);
182 182
void unmapnotify(XEvent *e);
186 186
void updatetilegeom(void);
187 187
void updatetitle(Client *c);
188 188
void updatewmhints(Client *c);
189 -
void view(const char *arg);
190 -
void viewprevtag(const char *arg);
189 +
void view(void *arg);
190 +
void viewprevtag(void *arg);
191 191
int xerror(Display *dpy, XErrorEvent *ee);
192 192
int xerrordummy(Display *dpy, XErrorEvent *ee);
193 193
int xerrorstart(Display *dpy, XErrorEvent *ee);
194 -
void zoom(const char *arg);
194 +
void zoom(void *arg);
195 195
196 196
/* variables */
197 197
char stext[256];
198 198
int screen, sx, sy, sw, sh;
199 199
int bx, by, bw, bh, blw, wx, wy, ww, wh;
200 200
int mx, my, mw, mh, tx, ty, tw, th;
201 -
int seltags = 0;
201 +
unsigned int seltags = 0;
202 202
int (*xerrorxlib)(Display *, XErrorEvent *);
203 203
unsigned int numlockmask = 0;
204 204
void (*handler[LASTEvent]) (XEvent *) = {
218 218
Atom wmatom[WMLast], netatom[NetLast];
219 219
Bool otherwm, readin;
220 220
Bool running = True;
221 -
Bool *tagset[2];
221 +
unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */
222 222
Client *clients = NULL;
223 223
Client *sel = NULL;
224 224
Client *stack = NULL;
231 231
232 232
/* configuration, allows nested code to access above variables */
233 233
#include "config.h"
234 -
#define TAGSZ (LENGTH(tags) * sizeof(Bool))
234 +
235 +
/* check if all tags will fit into a unsigned int bitarray. */
236 +
static char tags_is_a_sign_that_your_IQ[sizeof(int) * 8 < LENGTH(tags) ? -1 : 1];
235 237
236 238
/* function implementations */
237 239
238 240
void
239 241
applyrules(Client *c) {
240 242
	unsigned int i;
241 -
	Bool matched = False;
242 243
	Rule *r;
243 244
	XClassHint ch = { 0 };
244 245
250 251
		&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
251 252
		&& (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) {
252 253
			c->isfloating = r->isfloating;
253 -
			if(r->tag) {
254 -
				c->tags[idxoftag(r->tag)] = True;
255 -
				matched = True;
256 -
			}
254 +
			c->tags |= r->tags & TAGMASK;
257 255
		}
258 256
	}
259 257
	if(ch.res_class)
260 258
		XFree(ch.res_class);
261 259
	if(ch.res_name)
262 260
		XFree(ch.res_name);
263 -
	if(!matched)
264 -
		memcpy(c->tags, tagset[seltags], TAGSZ);
261 +
	if(!c->tags)
262 +
		c->tags = tagset[seltags];
265 263
}
266 264
267 265
void
307 305
308 306
void
309 307
buttonpress(XEvent *e) {
310 -
	unsigned int i, x;
308 +
	unsigned int i, x, mask;
311 309
	Client *c;
312 310
	XButtonPressedEvent *ev = &e->xbutton;
313 311
316 314
		for(i = 0; i < LENGTH(tags); i++) {
317 315
			x += textw(tags[i]);
318 316
			if(ev->x < x) {
317 +
				mask = 1 << i;
319 318
				if(ev->button == Button1) {
320 319
					if(ev->state & MODKEY)
321 -
						tag(tags[i]);
320 +
						tag(&mask);
322 321
					else
323 -
						view(tags[i]);
322 +
						view(&mask);
324 323
				}
325 324
				else if(ev->button == Button3) {
326 325
					if(ev->state & MODKEY)
327 -
						toggletag(tags[i]);
326 +
						toggletag(&mask);
328 327
					else
329 -
						toggleview(tags[i]);
328 +
						toggleview(&mask);
330 329
				}
331 330
				return;
332 331
			}
501 500
	for(c = stack; c && !isvisible(c); c = c->snext);
502 501
	for(i = 0; i < LENGTH(tags); i++) {
503 502
		dc.w = textw(tags[i]);
504 -
		if(tagset[seltags][i]) {
503 +
		if(tagset[seltags] & 1 << i) {
505 504
			drawtext(tags[i], dc.sel, isurgent(i));
506 -
			drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.sel);
505 +
			drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel);
507 506
		}
508 507
		else {
509 508
			drawtext(tags[i], dc.norm, isurgent(i));
510 -
			drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.norm);
509 +
			drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm);
511 510
		}
512 511
		dc.x += dc.w;
513 512
	}
668 667
}
669 668
670 669
void
671 -
focusnext(const char *arg) {
670 +
focusnext(void *arg) {
672 671
	Client *c;
673 672
674 673
	if(!sel)
683 682
}
684 683
685 684
void
686 -
focusprev(const char *arg) {
685 +
focusprev(void *arg) {
687 686
	Client *c;
688 687
689 688
	if(!sel)
808 807
	}
809 808
}
810 809
811 -
unsigned int
812 -
idxoftag(const char *t) {
813 -
	unsigned int i;
814 -
815 -
	for(i = 0; (i < LENGTH(tags)) && t && strcmp(tags[i], t); i++);
816 -
	return (i < LENGTH(tags)) ? i : 0;
817 -
}
818 -
819 810
void
820 811
initfont(const char *fontstr) {
821 812
	char *def, **missing;
861 852
	Client *c;
862 853
863 854
	for(c = clients; c; c = c->next)
864 -
		if(c->tags[t])
855 +
		if(c->tags & 1 << t)
865 856
			return True;
866 857
	return False;
867 858
}
886 877
	Client *c;
887 878
888 879
	for(c = clients; c; c = c->next)
889 -
		if(c->isurgent && c->tags[t])
880 +
		if(c->isurgent && c->tags & 1 << t)
890 881
			return True;
891 882
	return False;
892 883
}
893 884
894 885
Bool
895 886
isvisible(Client *c) {
896 -
	unsigned int i;
897 -
898 -
	for(i = 0; i < LENGTH(tags); i++)
899 -
		if(c->tags[i] && tagset[seltags][i])
900 -
			return True;
901 -
	return False;
887 +
	return c->tags & tagset[seltags];
902 888
}
903 889
904 890
void
919 905
}
920 906
921 907
void
922 -
killclient(const char *arg) {
908 +
killclient(void *arg) {
923 909
	XEvent ev;
924 910
925 911
	if(!sel)
945 931
	XWindowChanges wc;
946 932
947 933
	c = emallocz(sizeof(Client));
948 -
	c->tags = emallocz(TAGSZ);
949 934
	c->win = w;
950 935
951 936
	/* geometry */
980 965
	if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
981 966
		for(t = clients; t && t->win != trans; t = t->next);
982 967
	if(t)
983 -
		memcpy(c->tags, t->tags, TAGSZ);
968 +
		c->tags = t->tags;
984 969
	else
985 970
		applyrules(c);
986 971
	if(!c->isfloating)
1103 1088
}
1104 1089
1105 1090
void
1106 -
quit(const char *arg) {
1091 +
quit(void *arg) {
1107 1092
	readin = running = False;
1108 1093
}
1109 1094
1334 1319
			PropModeReplace, (unsigned char *)data, 2);
1335 1320
}
1336 1321
1322 +
/* arg > 1.0 will set mfact absolutly */
1337 1323
void
1338 -
setmfact(const char *arg) {
1339 -
	double d;
1324 +
setmfact(void *arg) {
1325 +
	double d = *((double*) arg);
1340 1326
1341 -
	if(!arg || lt->arrange != tile)
1327 +
	if(!d || lt->arrange != tile)
1342 1328
		return;
1343 -
	else {
1344 -
		d = strtod(arg, NULL);
1345 -
		if(arg[0] == '-' || arg[0] == '+')
1346 -
			d += mfact;
1347 -
		if(d < 0.1 || d > 0.9)
1348 -
			return;
1349 -
		mfact = d;
1350 -
	}
1329 +
	d = d < 1.0 ? d + mfact : d - 1.0;
1330 +
	if(d < 0.1 || d > 0.9)
1331 +
		return;
1332 +
	mfact = d;
1351 1333
	updatetilegeom();
1352 1334
	arrange();
1353 1335
}
1396 1378
	if(!dc.font.set)
1397 1379
		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
1398 1380
1399 -
	/* init tags */
1400 -
	tagset[0] = emallocz(TAGSZ);
1401 -
	tagset[1] = emallocz(TAGSZ);
1402 -
	tagset[0][0] = tagset[1][0] = True;
1403 -
1404 1381
	/* init bar */
1405 1382
	for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
1406 1383
		w = textw(layouts[i].symbol);
1435 1412
}
1436 1413
1437 1414
void
1438 -
spawn(const char *arg) {
1415 +
spawn(void *arg) {
1439 1416
	static char *shell = NULL;
1440 1417
1441 1418
	if(!shell && !(shell = getenv("SHELL")))
1442 1419
		shell = "/bin/sh";
1443 -
	if(!arg)
1444 -
		return;
1445 1420
	/* The double-fork construct avoids zombie processes and keeps the code
1446 1421
	 * clean from stupid signal handlers. */
1447 1422
	if(fork() == 0) {
1449 1424
			if(dpy)
1450 1425
				close(ConnectionNumber(dpy));
1451 1426
			setsid();
1452 -
			execl(shell, shell, "-c", arg, (char *)NULL);
1453 -
			fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg);
1427 +
			execl(shell, shell, "-c", (char *)arg, (char *)NULL);
1428 +
			fprintf(stderr, "dwm: execl '%s -c %s'", shell, (char *)arg);
1454 1429
			perror(" failed");
1455 1430
		}
1456 1431
		exit(0);
1459 1434
}
1460 1435
1461 1436
void
1462 -
tag(const char *arg) {
1463 -
	unsigned int i;
1464 -
1465 -
	if(!sel)
1466 -
		return;
1467 -
	for(i = 0; i < LENGTH(tags); i++)
1468 -
		sel->tags[i] = (arg == NULL);
1469 -
	sel->tags[idxoftag(arg)] = True;
1470 -
	arrange();
1437 +
tag(void *arg) {
1438 +
	if(sel && *(int *)arg & TAGMASK) {
1439 +
		sel->tags = *(int *)arg & TAGMASK;
1440 +
		arrange();
1441 +
	}
1471 1442
}
1472 1443
1473 1444
unsigned int
1534 1505
}
1535 1506
1536 1507
void
1537 -
togglebar(const char *arg) {
1508 +
togglebar(void *arg) {
1538 1509
	showbar = !showbar;
1539 1510
	updategeom();
1540 1511
	updatebar();
1542 1513
}
1543 1514
1544 1515
void
1545 -
togglefloating(const char *arg) {
1516 +
togglefloating(void *arg) {
1546 1517
	if(!sel)
1547 1518
		return;
1548 1519
	sel->isfloating = !sel->isfloating;
1552 1523
}
1553 1524
1554 1525
void
1555 -
togglelayout(const char *arg) {
1526 +
togglelayout(void *arg) {
1556 1527
	unsigned int i;
1557 1528
1558 1529
	if(!arg) {
1561 1532
	}
1562 1533
	else {
1563 1534
		for(i = 0; i < LENGTH(layouts); i++)
1564 -
			if(!strcmp(arg, layouts[i].symbol))
1535 +
			if(!strcmp((char *)arg, layouts[i].symbol))
1565 1536
				break;
1566 1537
		if(i == LENGTH(layouts))
1567 1538
			return;
1574 1545
}
1575 1546
1576 1547
void
1577 -
toggletag(const char *arg) {
1578 -
	unsigned int i, j;
1548 +
toggletag(void *arg) {
1549 +
	int i, m = *(int *)arg;
1550 +
	for(i = 0; i < sizeof(int) * 8; i++)
1551 +
		fputc(m & 1 << i ? '1' : '0', stdout);
1552 +
	puts("");
1553 +
	for(i = 0; i < sizeof(int) * 8; i++)
1554 +
		fputc(TAGMASK & 1 << i ? '1' : '0', stdout);
1555 +
	puts("aaa");
1579 1556
1580 -
	if(!sel)
1581 -
		return;
1582 -
	i = idxoftag(arg);
1583 -
	sel->tags[i] = !sel->tags[i];
1584 -
	for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++);
1585 -
	if(j == LENGTH(tags))
1586 -
		sel->tags[i] = True; /* at least one tag must be enabled */
1587 -
	arrange();
1557 +
	if(sel && (sel->tags ^ ((*(int *)arg) & TAGMASK))) {
1558 +
		sel->tags ^= (*(int *)arg) & TAGMASK;
1559 +
		arrange();
1560 +
	}
1588 1561
}
1589 1562
1590 1563
void
1591 -
toggleview(const char *arg) {
1592 -
	unsigned int i, j;
1593 -
1594 -
	i = idxoftag(arg);
1595 -
	tagset[seltags][i] = !tagset[seltags][i];
1596 -
	for(j = 0; j < LENGTH(tags) && !tagset[seltags][j]; j++);
1597 -
	if(j == LENGTH(tags))
1598 -
		tagset[seltags][i] = True; /* at least one tag must be viewed */
1599 -
	arrange();
1564 +
toggleview(void *arg) {
1565 +
	if((tagset[seltags] ^ ((*(int *)arg) & TAGMASK))) {
1566 +
		tagset[seltags] ^= (*(int *)arg) & TAGMASK;
1567 +
		arrange();
1568 +
	}
1600 1569
}
1601 1570
1602 1571
void
1622 1591
		focus(NULL);
1623 1592
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
1624 1593
	setclientstate(c, WithdrawnState);
1625 -
	free(c->tags);
1626 1594
	free(c);
1627 1595
	XSync(dpy, False);
1628 1596
	XSetErrorHandler(xerror);
1769 1737
}
1770 1738
1771 1739
void
1772 -
view(const char *arg) {
1773 -
	seltags ^= 1; /* toggle sel tagset */
1774 -
	memset(tagset[seltags], (NULL == arg), TAGSZ);
1775 -
	tagset[seltags][idxoftag(arg)] = True;
1776 -
	arrange();
1740 +
view(void *arg) {
1741 +
	if(*(int *)arg & TAGMASK) {
1742 +
		seltags ^= 1; /* toggle sel tagset */
1743 +
		tagset[seltags] = *(int *)arg & TAGMASK;
1744 +
		arrange();
1745 +
	}
1777 1746
}
1778 1747
1779 1748
void
1780 -
viewprevtag(const char *arg) {
1749 +
viewprevtag(void *arg) {
1781 1750
	seltags ^= 1; /* toggle sel tagset */
1782 1751
	arrange();
1783 1752
}
1816 1785
}
1817 1786
1818 1787
void
1819 -
zoom(const char *arg) {
1788 +
zoom(void *arg) {
1820 1789
	Client *c = sel;
1821 1790
1822 1791
	if(c == nextunfloating(clients))