summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@10kloc.org>2006-10-06 11:50:15 +0200
committerAnselm R. Garbe <arg@10kloc.org>2006-10-06 11:50:15 +0200
commit6651dd7fd9e8e95cfc6c472f1adfeff41735d798 (patch)
tree2ba87a8d0df487298c1507de1ec4b26867e0dd19
parentyet another small fix and simplification of dotile (diff)
downloaddwm-6651dd7fd9e8e95cfc6c472f1adfeff41735d798.tar.gz
dwm-6651dd7fd9e8e95cfc6c472f1adfeff41735d798.zip
code polishing, removed unnecessary newlines
-rw-r--r--client.c18
-rw-r--r--config.arg.h3
-rw-r--r--config.default.h3
-rw-r--r--draw.c14
-rw-r--r--dwm.h3
-rw-r--r--event.c9
-rw-r--r--main.c30
-rw-r--r--tag.c6
-rw-r--r--util.c5
-rw-r--r--view.c18
10 files changed, 23 insertions, 86 deletions
diff --git a/client.c b/client.c
index efa9669..60f1cbe 100644
--- a/client.c
+++ b/client.c
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5#include "dwm.h" 4#include "dwm.h"
@@ -156,7 +155,6 @@ gravitate(Client *c, Bool invert) {
156 dy = -(c->h); 155 dy = -(c->h);
157 break; 156 break;
158 } 157 }
159
160 switch (c->grav) { 158 switch (c->grav) {
161 default: 159 default:
162 break; 160 break;
@@ -177,7 +175,6 @@ gravitate(Client *c, Bool invert) {
177 dx = -(c->w + c->border); 175 dx = -(c->w + c->border);
178 break; 176 break;
179 } 177 }
180
181 if(invert) { 178 if(invert) {
182 dx = -dx; 179 dx = -dx;
183 dy = -dy; 180 dy = -dy;
@@ -210,10 +207,8 @@ manage(Window w, XWindowAttributes *wa) {
210 c->w = c->tw = wa->width; 207 c->w = c->tw = wa->width;
211 c->h = wa->height; 208 c->h = wa->height;
212 c->th = bh; 209 c->th = bh;
213
214 c->border = 0; 210 c->border = 0;
215 updatesize(c); 211 updatesize(c);
216
217 if(c->x + c->w + 2 * BORDERPX > sw) 212 if(c->x + c->w + 2 * BORDERPX > sw)
218 c->x = sw - c->w - 2 * BORDERPX; 213 c->x = sw - c->w - 2 * BORDERPX;
219 if(c->x < sx) 214 if(c->x < sx)
@@ -222,7 +217,6 @@ manage(Window w, XWindowAttributes *wa) {
222 c->y = sh - c->h - 2 * BORDERPX; 217 c->y = sh - c->h - 2 * BORDERPX;
223 if(c->h != sh && c->y < bh) 218 if(c->h != sh && c->y < bh)
224 c->y = bh; 219 c->y = bh;
225
226 c->proto = getproto(c->win); 220 c->proto = getproto(c->win);
227 XSelectInput(dpy, c->win, 221 XSelectInput(dpy, c->win,
228 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 222 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
@@ -230,12 +224,10 @@ manage(Window w, XWindowAttributes *wa) {
230 twa.override_redirect = 1; 224 twa.override_redirect = 1;
231 twa.background_pixmap = ParentRelative; 225 twa.background_pixmap = ParentRelative;
232 twa.event_mask = ExposureMask | EnterWindowMask; 226 twa.event_mask = ExposureMask | EnterWindowMask;
233
234 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, 227 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
235 0, DefaultDepth(dpy, screen), CopyFromParent, 228 0, DefaultDepth(dpy, screen), CopyFromParent,
236 DefaultVisual(dpy, screen), 229 DefaultVisual(dpy, screen),
237 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 230 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
238
239 grabbuttons(c, False); 231 grabbuttons(c, False);
240 updatetitle(c); 232 updatetitle(c);
241 settags(c, getclient(trans)); 233 settags(c, getclient(trans));
@@ -244,13 +236,11 @@ manage(Window w, XWindowAttributes *wa) {
244 || (c->maxw && c->minw && 236 || (c->maxw && c->minw &&
245 c->maxw == c->minw && c->maxh == c->minh); 237 c->maxw == c->minw && c->maxh == c->minh);
246 resizetitle(c); 238 resizetitle(c);
247
248 if(clients) 239 if(clients)
249 clients->prev = c; 240 clients->prev = c;
250 c->next = clients; 241 c->next = clients;
251 c->snext = stack; 242 c->snext = stack;
252 stack = clients = c; 243 stack = clients = c;
253
254 ban(c); 244 ban(c);
255 XMapWindow(dpy, c->win); 245 XMapWindow(dpy, c->win);
256 XMapWindow(dpy, c->twin); 246 XMapWindow(dpy, c->twin);
@@ -283,7 +273,6 @@ resize(Client *c, Bool sizehints, Corner sticky) {
283 c->x = right - c->w; 273 c->x = right - c->w;
284 if(sticky == BotLeft || sticky == BotRight) 274 if(sticky == BotLeft || sticky == BotRight)
285 c->y = bottom - c->h; 275 c->y = bottom - c->h;
286
287 /* offscreen appearance fixes */ 276 /* offscreen appearance fixes */
288 if(c->x + c->w < sx) 277 if(c->x + c->w < sx)
289 c->x = sx; 278 c->x = sx;
@@ -293,7 +282,6 @@ resize(Client *c, Bool sizehints, Corner sticky) {
293 c->x = sw - c->w; 282 c->x = sw - c->w;
294 if(c->y > sh) 283 if(c->y > sh)
295 c->y = sh - c->h; 284 c->y = sh - c->h;
296
297 resizetitle(c); 285 resizetitle(c);
298 wc.x = c->x; 286 wc.x = c->x;
299 wc.y = c->y; 287 wc.y = c->y;
@@ -392,20 +380,16 @@ unmanage(Client *c) {
392 /* The server grab construct avoids race conditions. */ 380 /* The server grab construct avoids race conditions. */
393 XGrabServer(dpy); 381 XGrabServer(dpy);
394 XSetErrorHandler(xerrordummy); 382 XSetErrorHandler(xerrordummy);
395
396 detach(c); 383 detach(c);
397 detachstack(c); 384 detachstack(c);
398 if(sel == c) { 385 if(sel == c) {
399 for(nc = stack; nc && !isvisible(nc); nc = nc->snext); 386 for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
400 focus(nc); 387 focus(nc);
401 } 388 }
402
403 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 389 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
404 XDestroyWindow(dpy, c->twin); 390 XDestroyWindow(dpy, c->twin);
405
406 free(c->tags); 391 free(c->tags);
407 free(c); 392 free(c);
408
409 XSync(dpy, False); 393 XSync(dpy, False);
410 XSetErrorHandler(xerror); 394 XSetErrorHandler(xerror);
411 XUngrabServer(dpy); 395 XUngrabServer(dpy);
diff --git a/config.arg.h b/config.arg.h
index 254d662..1a63ac8 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5 4
diff --git a/config.default.h b/config.default.h
index 9a6fbc6..dd402be 100644
--- a/config.default.h
+++ b/config.default.h
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5 4
diff --git a/draw.c b/draw.c
index c5cd35b..178f1d2 100644
--- a/draw.c
+++ b/draw.c
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5#include "dwm.h" 4#include "dwm.h"
@@ -30,21 +29,17 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
30 29
31 XSetForeground(dpy, dc.gc, col[ColBG]); 30 XSetForeground(dpy, dc.gc, col[ColBG]);
32 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); 31 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
33
34 if(!text) 32 if(!text)
35 return; 33 return;
36
37 w = 0; 34 w = 0;
38 olen = len = strlen(text); 35 olen = len = strlen(text);
39 if(len >= sizeof(buf)) 36 if(len >= sizeof(buf))
40 len = sizeof(buf) - 1; 37 len = sizeof(buf) - 1;
41 memcpy(buf, text, len); 38 memcpy(buf, text, len);
42 buf[len] = 0; 39 buf[len] = 0;
43
44 h = dc.font.ascent + dc.font.descent; 40 h = dc.font.ascent + dc.font.descent;
45 y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; 41 y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
46 x = dc.x + (h / 2); 42 x = dc.x + (h / 2);
47
48 /* shorten text if necessary */ 43 /* shorten text if necessary */
49 while(len && (w = textnw(buf, len)) > dc.w - h) 44 while(len && (w = textnw(buf, len)) > dc.w - h)
50 buf[--len] = 0; 45 buf[--len] = 0;
@@ -56,7 +51,6 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
56 if(len > 3) 51 if(len > 3)
57 buf[len - 3] = '.'; 52 buf[len - 3] = '.';
58 } 53 }
59
60 if(w > dc.w) 54 if(w > dc.w)
61 return; /* too long */ 55 return; /* too long */
62 gcv.foreground = col[ColFG]; 56 gcv.foreground = col[ColFG];
@@ -93,7 +87,6 @@ drawstatus(void) {
93 int i, x; 87 int i, x;
94 88
95 dc.x = dc.y = 0; 89 dc.x = dc.y = 0;
96
97 for(i = 0; i < ntags; i++) { 90 for(i = 0; i < ntags; i++) {
98 dc.w = textw(tags[i]); 91 dc.w = textw(tags[i]);
99 if(seltag[i]) 92 if(seltag[i])
@@ -102,10 +95,8 @@ drawstatus(void) {
102 drawtext(tags[i], dc.norm, sel && sel->tags[i]); 95 drawtext(tags[i], dc.norm, sel && sel->tags[i]);
103 dc.x += dc.w; 96 dc.x += dc.w;
104 } 97 }
105
106 dc.w = bmw; 98 dc.w = bmw;
107 drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False); 99 drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False);
108
109 x = dc.x + dc.w; 100 x = dc.x + dc.w;
110 dc.w = textw(stext); 101 dc.w = textw(stext);
111 dc.x = bx + bw - dc.w; 102 dc.x = bx + bw - dc.w;
@@ -114,7 +105,6 @@ drawstatus(void) {
114 dc.w = bw - x; 105 dc.w = bw - x;
115 } 106 }
116 drawtext(stext, dc.status, False); 107 drawtext(stext, dc.status, False);
117
118 if((dc.w = dc.x - x) > bh) { 108 if((dc.w = dc.x - x) > bh) {
119 dc.x = x; 109 dc.x = x;
120 if(sel) 110 if(sel)
@@ -134,7 +124,6 @@ drawtitle(Client *c) {
134 XSetWindowBorder(dpy, c->win, dc.sel[ColBG]); 124 XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
135 return; 125 return;
136 } 126 }
137
138 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); 127 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
139 XMapWindow(dpy, c->twin); 128 XMapWindow(dpy, c->twin);
140 dc.x = dc.y = 0; 129 dc.x = dc.y = 0;
@@ -177,7 +166,6 @@ setfont(const char *fontstr) {
177 XFontSetExtents *font_extents; 166 XFontSetExtents *font_extents;
178 XFontStruct **xfonts; 167 XFontStruct **xfonts;
179 char **font_names; 168 char **font_names;
180
181 dc.font.ascent = dc.font.descent = 0; 169 dc.font.ascent = dc.font.descent = 0;
182 font_extents = XExtentsOfFontSet(dc.font.set); 170 font_extents = XExtentsOfFontSet(dc.font.set);
183 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); 171 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
diff --git a/dwm.h b/dwm.h
index 0d00c25..be595a7 100644
--- a/dwm.h
+++ b/dwm.h
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 * 3 *
5 * dynamic window manager is designed like any other X client as well. It is 4 * dynamic window manager is designed like any other X client as well. It is
diff --git a/event.c b/event.c
index eab9b12..e959917 100644
--- a/event.c
+++ b/event.c
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5#include "dwm.h" 4#include "dwm.h"
@@ -64,7 +63,7 @@ resizemouse(Client *c) {
64 ocx = c->x; 63 ocx = c->x;
65 ocy = c->y; 64 ocy = c->y;
66 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, 65 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
67 None, cursor[CurResize], CurrentTime) != GrabSuccess) 66 None, cursor[CurResize], CurrentTime) != GrabSuccess)
68 return; 67 return;
69 c->ismax = False; 68 c->ismax = False;
70 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); 69 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
@@ -211,7 +210,6 @@ enternotify(XEvent *e) {
211 210
212 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) 211 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
213 return; 212 return;
214
215 if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c)) 213 if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c))
216 focus(c); 214 focus(c);
217 else if(ev->window == root) { 215 else if(ev->window == root) {
@@ -279,13 +277,11 @@ maprequest(XEvent *e) {
279 277
280 if(!XGetWindowAttributes(dpy, ev->window, &wa)) 278 if(!XGetWindowAttributes(dpy, ev->window, &wa))
281 return; 279 return;
282
283 if(wa.override_redirect) { 280 if(wa.override_redirect) {
284 XSelectInput(dpy, ev->window, 281 XSelectInput(dpy, ev->window,
285 (StructureNotifyMask | PropertyChangeMask)); 282 (StructureNotifyMask | PropertyChangeMask));
286 return; 283 return;
287 } 284 }
288
289 if(!getclient(ev->window)) 285 if(!getclient(ev->window))
290 manage(ev->window, &wa); 286 manage(ev->window, &wa);
291} 287}
@@ -298,7 +294,6 @@ propertynotify(XEvent *e) {
298 294
299 if(ev->state == PropertyDelete) 295 if(ev->state == PropertyDelete)
300 return; /* ignore */ 296 return; /* ignore */
301
302 if((c = getclient(ev->window))) { 297 if((c = getclient(ev->window))) {
303 if(ev->atom == wmatom[WMProtocols]) { 298 if(ev->atom == wmatom[WMProtocols]) {
304 c->proto = getproto(c->win); 299 c->proto = getproto(c->win);
diff --git a/main.c b/main.c
index b627e51..1e58176 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5 4
@@ -93,12 +92,11 @@ setup(void) {
93 netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); 92 netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
94 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, 93 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
95 PropModeReplace, (unsigned char *) netatom, NetLast); 94 PropModeReplace, (unsigned char *) netatom, NetLast);
96
97 /* init cursors */ 95 /* init cursors */
98 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); 96 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
99 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); 97 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
100 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); 98 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
101 99 /* init modifier map */
102 modmap = XGetModifierMapping(dpy); 100 modmap = XGetModifierMapping(dpy);
103 for (i = 0; i < 8; i++) { 101 for (i = 0; i < 8; i++) {
104 for (j = 0; j < modmap->max_keypermod; j++) { 102 for (j = 0; j < modmap->max_keypermod; j++) {
@@ -107,19 +105,16 @@ setup(void) {
107 } 105 }
108 } 106 }
109 XFree(modmap); 107 XFree(modmap);
110 108 /* select for events */
111 wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask 109 wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
112 | EnterWindowMask | LeaveWindowMask; 110 | EnterWindowMask | LeaveWindowMask;
113 wa.cursor = cursor[CurNormal]; 111 wa.cursor = cursor[CurNormal];
114 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); 112 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
115
116 grabkeys(); 113 grabkeys();
117 initrregs(); 114 initrregs();
118
119 for(ntags = 0; tags[ntags]; ntags++); 115 for(ntags = 0; tags[ntags]; ntags++);
120 seltag = emallocz(sizeof(Bool) * ntags); 116 seltag = emallocz(sizeof(Bool) * ntags);
121 seltag[0] = True; 117 seltag[0] = True;
122
123 /* style */ 118 /* style */
124 dc.norm[ColBG] = getcolor(NORMBGCOLOR); 119 dc.norm[ColBG] = getcolor(NORMBGCOLOR);
125 dc.norm[ColFG] = getcolor(NORMFGCOLOR); 120 dc.norm[ColFG] = getcolor(NORMFGCOLOR);
@@ -128,13 +123,13 @@ setup(void) {
128 dc.status[ColBG] = getcolor(STATUSBGCOLOR); 123 dc.status[ColBG] = getcolor(STATUSBGCOLOR);
129 dc.status[ColFG] = getcolor(STATUSFGCOLOR); 124 dc.status[ColFG] = getcolor(STATUSFGCOLOR);
130 setfont(FONT); 125 setfont(FONT);
131 126 /* geometry */
132 bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL); 127 bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL);
133 sx = sy = 0; 128 sx = sy = 0;
134 sw = DisplayWidth(dpy, screen); 129 sw = DisplayWidth(dpy, screen);
135 sh = DisplayHeight(dpy, screen); 130 sh = DisplayHeight(dpy, screen);
136 master = MASTER; 131 master = MASTER;
137 132 /* bar */
138 bx = by = 0; 133 bx = by = 0;
139 bw = sw; 134 bw = sw;
140 dc.h = bh = dc.font.height + 2; 135 dc.h = bh = dc.font.height + 2;
@@ -146,13 +141,13 @@ setup(void) {
146 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 141 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
147 XDefineCursor(dpy, barwin, cursor[CurNormal]); 142 XDefineCursor(dpy, barwin, cursor[CurNormal]);
148 XMapRaised(dpy, barwin); 143 XMapRaised(dpy, barwin);
149 144 strcpy(stext, "dwm-"VERSION);
145 /* pixmap for everything */
150 dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); 146 dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
151 dc.gc = XCreateGC(dpy, root, 0, 0); 147 dc.gc = XCreateGC(dpy, root, 0, 0);
152 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); 148 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
153 149 /* multihead support */
154 issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); 150 issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
155 strcpy(stext, "dwm-"VERSION);
156} 151}
157 152
158/* 153/*
@@ -204,8 +199,7 @@ quit(Arg *arg) {
204 readin = running = False; 199 readin = running = False;
205} 200}
206 201
207/* 202/* There's no way to check accesses to destroyed windows, thus those cases are
208 * There's no way to check accesses to destroyed windows, thus those cases are
209 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs 203 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs
210 * default error handler, which may call exit. 204 * default error handler, which may call exit.
211 */ 205 */
@@ -236,21 +230,17 @@ main(int argc, char *argv[]) {
236 } 230 }
237 else if(argc != 1) 231 else if(argc != 1)
238 eprint("usage: dwm [-v]\n"); 232 eprint("usage: dwm [-v]\n");
239
240 dpy = XOpenDisplay(0); 233 dpy = XOpenDisplay(0);
241 if(!dpy) 234 if(!dpy)
242 eprint("dwm: cannot open display\n"); 235 eprint("dwm: cannot open display\n");
243
244 xfd = ConnectionNumber(dpy); 236 xfd = ConnectionNumber(dpy);
245 screen = DefaultScreen(dpy); 237 screen = DefaultScreen(dpy);
246 root = RootWindow(dpy, screen); 238 root = RootWindow(dpy, screen);
247
248 otherwm = False; 239 otherwm = False;
249 XSetErrorHandler(xerrorstart); 240 XSetErrorHandler(xerrorstart);
250 /* this causes an error if some other window manager is running */ 241 /* this causes an error if some other window manager is running */
251 XSelectInput(dpy, root, SubstructureRedirectMask); 242 XSelectInput(dpy, root, SubstructureRedirectMask);
252 XSync(dpy, False); 243 XSync(dpy, False);
253
254 if(otherwm) 244 if(otherwm)
255 eprint("dwm: another window manager is already running\n"); 245 eprint("dwm: another window manager is already running\n");
256 246
@@ -258,7 +248,6 @@ main(int argc, char *argv[]) {
258 XSetErrorHandler(NULL); 248 XSetErrorHandler(NULL);
259 xerrorxlib = XSetErrorHandler(xerror); 249 xerrorxlib = XSetErrorHandler(xerror);
260 XSync(dpy, False); 250 XSync(dpy, False);
261
262 setup(); 251 setup();
263 drawstatus(); 252 drawstatus();
264 scan(); 253 scan();
@@ -291,6 +280,5 @@ main(int argc, char *argv[]) {
291 } 280 }
292 cleanup(); 281 cleanup();
293 XCloseDisplay(dpy); 282 XCloseDisplay(dpy);
294
295 return 0; 283 return 0;
296} 284}
diff --git a/tag.c b/tag.c
index eda1543..70a1553 100644
--- a/tag.c
+++ b/tag.c
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5#include "dwm.h" 4#include "dwm.h"
@@ -53,7 +52,6 @@ initrregs(void) {
53 return; 52 return;
54 len = sizeof(rule) / sizeof(rule[0]); 53 len = sizeof(rule) / sizeof(rule[0]);
55 rreg = emallocz(len * sizeof(RReg)); 54 rreg = emallocz(len * sizeof(RReg));
56
57 for(i = 0; i < len; i++) { 55 for(i = 0; i < len; i++) {
58 if(rule[i].clpattern) { 56 if(rule[i].clpattern) {
59 reg = emallocz(sizeof(regex_t)); 57 reg = emallocz(sizeof(regex_t));
@@ -115,7 +113,6 @@ tag(Arg *arg) {
115 113
116 if(!sel) 114 if(!sel)
117 return; 115 return;
118
119 for(i = 0; i < ntags; i++) 116 for(i = 0; i < ntags; i++)
120 sel->tags[i] = False; 117 sel->tags[i] = False;
121 sel->tags[arg->i] = True; 118 sel->tags[arg->i] = True;
@@ -129,7 +126,6 @@ toggletag(Arg *arg) {
129 126
130 if(!sel) 127 if(!sel)
131 return; 128 return;
132
133 sel->tags[arg->i] = !sel->tags[arg->i]; 129 sel->tags[arg->i] = !sel->tags[arg->i];
134 for(i = 0; i < ntags && !sel->tags[i]; i++); 130 for(i = 0; i < ntags && !sel->tags[i]; i++);
135 if(i == ntags) 131 if(i == ntags)
diff --git a/util.c b/util.c
index c31d7f9..abd82de 100644
--- a/util.c
+++ b/util.c
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5#include "dwm.h" 4#include "dwm.h"
@@ -33,6 +32,7 @@ eprint(const char *errstr, ...) {
33void * 32void *
34erealloc(void *ptr, unsigned int size) { 33erealloc(void *ptr, unsigned int size) {
35 void *res = realloc(ptr, size); 34 void *res = realloc(ptr, size);
35
36 if(!res) 36 if(!res)
37 eprint("fatal: could not malloc() %u bytes\n", size); 37 eprint("fatal: could not malloc() %u bytes\n", size);
38 return res; 38 return res;
@@ -44,7 +44,6 @@ spawn(Arg *arg) {
44 44
45 if(!shell && !(shell = getenv("SHELL"))) 45 if(!shell && !(shell = getenv("SHELL")))
46 shell = "/bin/sh"; 46 shell = "/bin/sh";
47
48 if(!arg->cmd) 47 if(!arg->cmd)
49 return; 48 return;
50 /* The double-fork construct avoids zombie processes and keeps the code 49 /* The double-fork construct avoids zombie processes and keeps the code
diff --git a/view.c b/view.c
index b2f2614..24b0349 100644
--- a/view.c
+++ b/view.c
@@ -1,5 +1,4 @@
1/* 1/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5#include "dwm.h" 4#include "dwm.h"
@@ -43,9 +42,9 @@ reorder(void) {
43} 42}
44 43
45static void 44static void
46togglemax(Client *c) 45togglemax(Client *c) {
47{
48 XEvent ev; 46 XEvent ev;
47
49 if((c->ismax = !c->ismax)) { 48 if((c->ismax = !c->ismax)) {
50 c->rx = c->x; c->x = sx; 49 c->rx = c->x; c->x = sx;
51 c->ry = c->y; c->y = bh; 50 c->ry = c->y; c->y = bh;
@@ -102,11 +101,9 @@ dotile(Arg *arg) {
102 101
103 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 102 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
104 n++; 103 n++;
105
106 mpx = (sw * master) / 1000; 104 mpx = (sw * master) / 1000;
107 stackw = sw - mpx; 105 stackw = sw - mpx;
108 stackh = sh - bh; 106 stackh = sh - bh;
109
110 th = stackh; 107 th = stackh;
111 if(n > 1) 108 if(n > 1)
112 th /= (n - 1); 109 th /= (n - 1);
@@ -145,6 +142,7 @@ dotile(Arg *arg) {
145 } 142 }
146 else 143 else
147 ban(c); 144 ban(c);
145
148 if(!sel || !isvisible(sel)) { 146 if(!sel || !isvisible(sel)) {
149 for(c = stack; c && !isvisible(c); c = c->snext); 147 for(c = stack; c && !isvisible(c); c = c->snext);
150 focus(c); 148 focus(c);
@@ -158,7 +156,6 @@ focusnext(Arg *arg) {
158 156
159 if(!sel) 157 if(!sel)
160 return; 158 return;
161
162 if(!(c = getnext(sel->next))) 159 if(!(c = getnext(sel->next)))
163 c = getnext(clients); 160 c = getnext(clients);
164 if(c) { 161 if(c) {
@@ -173,7 +170,6 @@ focusprev(Arg *arg) {
173 170
174 if(!sel) 171 if(!sel)
175 return; 172 return;
176
177 if(!(c = getprev(sel->prev))) { 173 if(!(c = getprev(sel->prev))) {
178 for(c = clients; c && c->next; c = c->next); 174 for(c = clients; c && c->next; c = c->next);
179 c = getprev(c); 175 c = getprev(c);
@@ -204,7 +200,6 @@ resizecol(Arg *arg) {
204 n++; 200 n++;
205 if(!sel || sel->isfloat || n < 2 || (arrange == dofloat)) 201 if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
206 return; 202 return;
207
208 if(sel == getnext(clients)) { 203 if(sel == getnext(clients)) {
209 if(master + arg->i > 950 || master + arg->i < 50) 204 if(master + arg->i > 950 || master + arg->i < 50)
210 return; 205 return;
@@ -290,8 +285,6 @@ viewall(Arg *arg) {
290 arrange(NULL); 285 arrange(NULL);
291} 286}
292 287
293
294
295void 288void
296zoom(Arg *arg) { 289zoom(Arg *arg) {
297 unsigned int n; 290 unsigned int n;
@@ -299,18 +292,15 @@ zoom(Arg *arg) {
299 292
300 if(!sel) 293 if(!sel)
301 return; 294 return;
302
303 if(sel->isfloat || (arrange == dofloat)) { 295 if(sel->isfloat || (arrange == dofloat)) {
304 togglemax(sel); 296 togglemax(sel);
305 return; 297 return;
306 } 298 }
307
308 for(n = 0, c = clients; c; c = c->next) 299 for(n = 0, c = clients; c; c = c->next)
309 if(isvisible(c) && !c->isfloat) 300 if(isvisible(c) && !c->isfloat)
310 n++; 301 n++;
311 if(n < 2 || (arrange == dofloat)) 302 if(n < 2 || (arrange == dofloat))
312 return; 303 return;
313
314 if((c = sel) == nexttiled(clients)) 304 if((c = sel) == nexttiled(clients))
315 if(!(c = nexttiled(c->next))) 305 if(!(c = nexttiled(c->next)))
316 return; 306 return;