dwm-meillo
changeset 532:651f2c868b31
code polishing, removed unnecessary newlines
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Fri, 06 Oct 2006 11:50:15 +0200 |
parents | 96563762b4ad |
children | a5567a0d3011 |
files | client.c config.arg.h config.default.h draw.c dwm.h event.c main.c tag.c util.c view.c |
diffstat | 10 files changed, 23 insertions(+), 86 deletions(-) [+] |
line diff
1.1 --- a/client.c Fri Oct 06 11:37:12 2006 +0200 1.2 +++ b/client.c Fri Oct 06 11:50:15 2006 +0200 1.3 @@ -1,5 +1,4 @@ 1.4 -/* 1.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 1.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 1.7 * See LICENSE file for license details. 1.8 */ 1.9 #include "dwm.h" 1.10 @@ -156,7 +155,6 @@ 1.11 dy = -(c->h); 1.12 break; 1.13 } 1.14 - 1.15 switch (c->grav) { 1.16 default: 1.17 break; 1.18 @@ -177,7 +175,6 @@ 1.19 dx = -(c->w + c->border); 1.20 break; 1.21 } 1.22 - 1.23 if(invert) { 1.24 dx = -dx; 1.25 dy = -dy; 1.26 @@ -210,10 +207,8 @@ 1.27 c->w = c->tw = wa->width; 1.28 c->h = wa->height; 1.29 c->th = bh; 1.30 - 1.31 c->border = 0; 1.32 updatesize(c); 1.33 - 1.34 if(c->x + c->w + 2 * BORDERPX > sw) 1.35 c->x = sw - c->w - 2 * BORDERPX; 1.36 if(c->x < sx) 1.37 @@ -222,7 +217,6 @@ 1.38 c->y = sh - c->h - 2 * BORDERPX; 1.39 if(c->h != sh && c->y < bh) 1.40 c->y = bh; 1.41 - 1.42 c->proto = getproto(c->win); 1.43 XSelectInput(dpy, c->win, 1.44 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 1.45 @@ -230,12 +224,10 @@ 1.46 twa.override_redirect = 1; 1.47 twa.background_pixmap = ParentRelative; 1.48 twa.event_mask = ExposureMask | EnterWindowMask; 1.49 - 1.50 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, 1.51 0, DefaultDepth(dpy, screen), CopyFromParent, 1.52 DefaultVisual(dpy, screen), 1.53 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 1.54 - 1.55 grabbuttons(c, False); 1.56 updatetitle(c); 1.57 settags(c, getclient(trans)); 1.58 @@ -244,13 +236,11 @@ 1.59 || (c->maxw && c->minw && 1.60 c->maxw == c->minw && c->maxh == c->minh); 1.61 resizetitle(c); 1.62 - 1.63 if(clients) 1.64 clients->prev = c; 1.65 c->next = clients; 1.66 c->snext = stack; 1.67 stack = clients = c; 1.68 - 1.69 ban(c); 1.70 XMapWindow(dpy, c->win); 1.71 XMapWindow(dpy, c->twin); 1.72 @@ -283,7 +273,6 @@ 1.73 c->x = right - c->w; 1.74 if(sticky == BotLeft || sticky == BotRight) 1.75 c->y = bottom - c->h; 1.76 - 1.77 /* offscreen appearance fixes */ 1.78 if(c->x + c->w < sx) 1.79 c->x = sx; 1.80 @@ -293,7 +282,6 @@ 1.81 c->x = sw - c->w; 1.82 if(c->y > sh) 1.83 c->y = sh - c->h; 1.84 - 1.85 resizetitle(c); 1.86 wc.x = c->x; 1.87 wc.y = c->y; 1.88 @@ -392,20 +380,16 @@ 1.89 /* The server grab construct avoids race conditions. */ 1.90 XGrabServer(dpy); 1.91 XSetErrorHandler(xerrordummy); 1.92 - 1.93 detach(c); 1.94 detachstack(c); 1.95 if(sel == c) { 1.96 for(nc = stack; nc && !isvisible(nc); nc = nc->snext); 1.97 focus(nc); 1.98 } 1.99 - 1.100 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.101 XDestroyWindow(dpy, c->twin); 1.102 - 1.103 free(c->tags); 1.104 free(c); 1.105 - 1.106 XSync(dpy, False); 1.107 XSetErrorHandler(xerror); 1.108 XUngrabServer(dpy);
2.1 --- a/config.arg.h Fri Oct 06 11:37:12 2006 +0200 2.2 +++ b/config.arg.h Fri Oct 06 11:50:15 2006 +0200 2.3 @@ -1,5 +1,4 @@ 2.4 -/* 2.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 2.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 2.7 * See LICENSE file for license details. 2.8 */ 2.9
3.1 --- a/config.default.h Fri Oct 06 11:37:12 2006 +0200 3.2 +++ b/config.default.h Fri Oct 06 11:50:15 2006 +0200 3.3 @@ -1,5 +1,4 @@ 3.4 -/* 3.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 3.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 3.7 * See LICENSE file for license details. 3.8 */ 3.9
4.1 --- a/draw.c Fri Oct 06 11:37:12 2006 +0200 4.2 +++ b/draw.c Fri Oct 06 11:50:15 2006 +0200 4.3 @@ -1,5 +1,4 @@ 4.4 -/* 4.5 - * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com> 4.6 +/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com> 4.7 * See LICENSE file for license details. 4.8 */ 4.9 #include "dwm.h" 4.10 @@ -30,21 +29,17 @@ 4.11 4.12 XSetForeground(dpy, dc.gc, col[ColBG]); 4.13 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); 4.14 - 4.15 if(!text) 4.16 return; 4.17 - 4.18 w = 0; 4.19 olen = len = strlen(text); 4.20 if(len >= sizeof(buf)) 4.21 len = sizeof(buf) - 1; 4.22 memcpy(buf, text, len); 4.23 buf[len] = 0; 4.24 - 4.25 h = dc.font.ascent + dc.font.descent; 4.26 y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; 4.27 x = dc.x + (h / 2); 4.28 - 4.29 /* shorten text if necessary */ 4.30 while(len && (w = textnw(buf, len)) > dc.w - h) 4.31 buf[--len] = 0; 4.32 @@ -56,7 +51,6 @@ 4.33 if(len > 3) 4.34 buf[len - 3] = '.'; 4.35 } 4.36 - 4.37 if(w > dc.w) 4.38 return; /* too long */ 4.39 gcv.foreground = col[ColFG]; 4.40 @@ -93,7 +87,6 @@ 4.41 int i, x; 4.42 4.43 dc.x = dc.y = 0; 4.44 - 4.45 for(i = 0; i < ntags; i++) { 4.46 dc.w = textw(tags[i]); 4.47 if(seltag[i]) 4.48 @@ -102,10 +95,8 @@ 4.49 drawtext(tags[i], dc.norm, sel && sel->tags[i]); 4.50 dc.x += dc.w; 4.51 } 4.52 - 4.53 dc.w = bmw; 4.54 drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False); 4.55 - 4.56 x = dc.x + dc.w; 4.57 dc.w = textw(stext); 4.58 dc.x = bx + bw - dc.w; 4.59 @@ -114,7 +105,6 @@ 4.60 dc.w = bw - x; 4.61 } 4.62 drawtext(stext, dc.status, False); 4.63 - 4.64 if((dc.w = dc.x - x) > bh) { 4.65 dc.x = x; 4.66 if(sel) 4.67 @@ -134,7 +124,6 @@ 4.68 XSetWindowBorder(dpy, c->win, dc.sel[ColBG]); 4.69 return; 4.70 } 4.71 - 4.72 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); 4.73 XMapWindow(dpy, c->twin); 4.74 dc.x = dc.y = 0; 4.75 @@ -177,7 +166,6 @@ 4.76 XFontSetExtents *font_extents; 4.77 XFontStruct **xfonts; 4.78 char **font_names; 4.79 - 4.80 dc.font.ascent = dc.font.descent = 0; 4.81 font_extents = XExtentsOfFontSet(dc.font.set); 4.82 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
5.1 --- a/dwm.h Fri Oct 06 11:37:12 2006 +0200 5.2 +++ b/dwm.h Fri Oct 06 11:50:15 2006 +0200 5.3 @@ -1,5 +1,4 @@ 5.4 -/* 5.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 5.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 5.7 * See LICENSE file for license details. 5.8 * 5.9 * dynamic window manager is designed like any other X client as well. It is
6.1 --- a/event.c Fri Oct 06 11:37:12 2006 +0200 6.2 +++ b/event.c Fri Oct 06 11:50:15 2006 +0200 6.3 @@ -1,5 +1,4 @@ 6.4 -/* 6.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 6.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 6.7 * See LICENSE file for license details. 6.8 */ 6.9 #include "dwm.h" 6.10 @@ -64,7 +63,7 @@ 6.11 ocx = c->x; 6.12 ocy = c->y; 6.13 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, 6.14 - None, cursor[CurResize], CurrentTime) != GrabSuccess) 6.15 + None, cursor[CurResize], CurrentTime) != GrabSuccess) 6.16 return; 6.17 c->ismax = False; 6.18 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); 6.19 @@ -211,7 +210,6 @@ 6.20 6.21 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) 6.22 return; 6.23 - 6.24 if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c)) 6.25 focus(c); 6.26 else if(ev->window == root) { 6.27 @@ -279,13 +277,11 @@ 6.28 6.29 if(!XGetWindowAttributes(dpy, ev->window, &wa)) 6.30 return; 6.31 - 6.32 if(wa.override_redirect) { 6.33 XSelectInput(dpy, ev->window, 6.34 (StructureNotifyMask | PropertyChangeMask)); 6.35 return; 6.36 } 6.37 - 6.38 if(!getclient(ev->window)) 6.39 manage(ev->window, &wa); 6.40 } 6.41 @@ -298,7 +294,6 @@ 6.42 6.43 if(ev->state == PropertyDelete) 6.44 return; /* ignore */ 6.45 - 6.46 if((c = getclient(ev->window))) { 6.47 if(ev->atom == wmatom[WMProtocols]) { 6.48 c->proto = getproto(c->win);
7.1 --- a/main.c Fri Oct 06 11:37:12 2006 +0200 7.2 +++ b/main.c Fri Oct 06 11:50:15 2006 +0200 7.3 @@ -1,5 +1,4 @@ 7.4 -/* 7.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 7.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 7.7 * See LICENSE file for license details. 7.8 */ 7.9 7.10 @@ -93,12 +92,11 @@ 7.11 netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); 7.12 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, 7.13 PropModeReplace, (unsigned char *) netatom, NetLast); 7.14 - 7.15 /* init cursors */ 7.16 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); 7.17 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); 7.18 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); 7.19 - 7.20 + /* init modifier map */ 7.21 modmap = XGetModifierMapping(dpy); 7.22 for (i = 0; i < 8; i++) { 7.23 for (j = 0; j < modmap->max_keypermod; j++) { 7.24 @@ -107,19 +105,16 @@ 7.25 } 7.26 } 7.27 XFree(modmap); 7.28 - 7.29 + /* select for events */ 7.30 wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask 7.31 | EnterWindowMask | LeaveWindowMask; 7.32 wa.cursor = cursor[CurNormal]; 7.33 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); 7.34 - 7.35 grabkeys(); 7.36 initrregs(); 7.37 - 7.38 for(ntags = 0; tags[ntags]; ntags++); 7.39 seltag = emallocz(sizeof(Bool) * ntags); 7.40 seltag[0] = True; 7.41 - 7.42 /* style */ 7.43 dc.norm[ColBG] = getcolor(NORMBGCOLOR); 7.44 dc.norm[ColFG] = getcolor(NORMFGCOLOR); 7.45 @@ -128,13 +123,13 @@ 7.46 dc.status[ColBG] = getcolor(STATUSBGCOLOR); 7.47 dc.status[ColFG] = getcolor(STATUSFGCOLOR); 7.48 setfont(FONT); 7.49 - 7.50 + /* geometry */ 7.51 bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL); 7.52 sx = sy = 0; 7.53 sw = DisplayWidth(dpy, screen); 7.54 sh = DisplayHeight(dpy, screen); 7.55 master = MASTER; 7.56 - 7.57 + /* bar */ 7.58 bx = by = 0; 7.59 bw = sw; 7.60 dc.h = bh = dc.font.height + 2; 7.61 @@ -146,13 +141,13 @@ 7.62 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 7.63 XDefineCursor(dpy, barwin, cursor[CurNormal]); 7.64 XMapRaised(dpy, barwin); 7.65 - 7.66 + strcpy(stext, "dwm-"VERSION); 7.67 + /* pixmap for everything */ 7.68 dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); 7.69 dc.gc = XCreateGC(dpy, root, 0, 0); 7.70 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); 7.71 - 7.72 + /* multihead support */ 7.73 issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); 7.74 - strcpy(stext, "dwm-"VERSION); 7.75 } 7.76 7.77 /* 7.78 @@ -204,8 +199,7 @@ 7.79 readin = running = False; 7.80 } 7.81 7.82 -/* 7.83 - * There's no way to check accesses to destroyed windows, thus those cases are 7.84 +/* There's no way to check accesses to destroyed windows, thus those cases are 7.85 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs 7.86 * default error handler, which may call exit. 7.87 */ 7.88 @@ -236,21 +230,17 @@ 7.89 } 7.90 else if(argc != 1) 7.91 eprint("usage: dwm [-v]\n"); 7.92 - 7.93 dpy = XOpenDisplay(0); 7.94 if(!dpy) 7.95 eprint("dwm: cannot open display\n"); 7.96 - 7.97 xfd = ConnectionNumber(dpy); 7.98 screen = DefaultScreen(dpy); 7.99 root = RootWindow(dpy, screen); 7.100 - 7.101 otherwm = False; 7.102 XSetErrorHandler(xerrorstart); 7.103 /* this causes an error if some other window manager is running */ 7.104 XSelectInput(dpy, root, SubstructureRedirectMask); 7.105 XSync(dpy, False); 7.106 - 7.107 if(otherwm) 7.108 eprint("dwm: another window manager is already running\n"); 7.109 7.110 @@ -258,7 +248,6 @@ 7.111 XSetErrorHandler(NULL); 7.112 xerrorxlib = XSetErrorHandler(xerror); 7.113 XSync(dpy, False); 7.114 - 7.115 setup(); 7.116 drawstatus(); 7.117 scan(); 7.118 @@ -291,6 +280,5 @@ 7.119 } 7.120 cleanup(); 7.121 XCloseDisplay(dpy); 7.122 - 7.123 return 0; 7.124 }
8.1 --- a/tag.c Fri Oct 06 11:37:12 2006 +0200 8.2 +++ b/tag.c Fri Oct 06 11:50:15 2006 +0200 8.3 @@ -1,5 +1,4 @@ 8.4 -/* 8.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 8.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 8.7 * See LICENSE file for license details. 8.8 */ 8.9 #include "dwm.h" 8.10 @@ -53,7 +52,6 @@ 8.11 return; 8.12 len = sizeof(rule) / sizeof(rule[0]); 8.13 rreg = emallocz(len * sizeof(RReg)); 8.14 - 8.15 for(i = 0; i < len; i++) { 8.16 if(rule[i].clpattern) { 8.17 reg = emallocz(sizeof(regex_t)); 8.18 @@ -115,7 +113,6 @@ 8.19 8.20 if(!sel) 8.21 return; 8.22 - 8.23 for(i = 0; i < ntags; i++) 8.24 sel->tags[i] = False; 8.25 sel->tags[arg->i] = True; 8.26 @@ -129,7 +126,6 @@ 8.27 8.28 if(!sel) 8.29 return; 8.30 - 8.31 sel->tags[arg->i] = !sel->tags[arg->i]; 8.32 for(i = 0; i < ntags && !sel->tags[i]; i++); 8.33 if(i == ntags)
9.1 --- a/util.c Fri Oct 06 11:37:12 2006 +0200 9.2 +++ b/util.c Fri Oct 06 11:50:15 2006 +0200 9.3 @@ -1,5 +1,4 @@ 9.4 -/* 9.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 9.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 9.7 * See LICENSE file for license details. 9.8 */ 9.9 #include "dwm.h" 9.10 @@ -33,6 +32,7 @@ 9.11 void * 9.12 erealloc(void *ptr, unsigned int size) { 9.13 void *res = realloc(ptr, size); 9.14 + 9.15 if(!res) 9.16 eprint("fatal: could not malloc() %u bytes\n", size); 9.17 return res; 9.18 @@ -44,7 +44,6 @@ 9.19 9.20 if(!shell && !(shell = getenv("SHELL"))) 9.21 shell = "/bin/sh"; 9.22 - 9.23 if(!arg->cmd) 9.24 return; 9.25 /* The double-fork construct avoids zombie processes and keeps the code
10.1 --- a/view.c Fri Oct 06 11:37:12 2006 +0200 10.2 +++ b/view.c Fri Oct 06 11:50:15 2006 +0200 10.3 @@ -1,5 +1,4 @@ 10.4 -/* 10.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 10.6 +/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 10.7 * See LICENSE file for license details. 10.8 */ 10.9 #include "dwm.h" 10.10 @@ -43,9 +42,9 @@ 10.11 } 10.12 10.13 static void 10.14 -togglemax(Client *c) 10.15 -{ 10.16 +togglemax(Client *c) { 10.17 XEvent ev; 10.18 + 10.19 if((c->ismax = !c->ismax)) { 10.20 c->rx = c->x; c->x = sx; 10.21 c->ry = c->y; c->y = bh; 10.22 @@ -102,11 +101,9 @@ 10.23 10.24 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 10.25 n++; 10.26 - 10.27 mpx = (sw * master) / 1000; 10.28 stackw = sw - mpx; 10.29 stackh = sh - bh; 10.30 - 10.31 th = stackh; 10.32 if(n > 1) 10.33 th /= (n - 1); 10.34 @@ -145,6 +142,7 @@ 10.35 } 10.36 else 10.37 ban(c); 10.38 + 10.39 if(!sel || !isvisible(sel)) { 10.40 for(c = stack; c && !isvisible(c); c = c->snext); 10.41 focus(c); 10.42 @@ -158,7 +156,6 @@ 10.43 10.44 if(!sel) 10.45 return; 10.46 - 10.47 if(!(c = getnext(sel->next))) 10.48 c = getnext(clients); 10.49 if(c) { 10.50 @@ -173,7 +170,6 @@ 10.51 10.52 if(!sel) 10.53 return; 10.54 - 10.55 if(!(c = getprev(sel->prev))) { 10.56 for(c = clients; c && c->next; c = c->next); 10.57 c = getprev(c); 10.58 @@ -204,7 +200,6 @@ 10.59 n++; 10.60 if(!sel || sel->isfloat || n < 2 || (arrange == dofloat)) 10.61 return; 10.62 - 10.63 if(sel == getnext(clients)) { 10.64 if(master + arg->i > 950 || master + arg->i < 50) 10.65 return; 10.66 @@ -290,8 +285,6 @@ 10.67 arrange(NULL); 10.68 } 10.69 10.70 - 10.71 - 10.72 void 10.73 zoom(Arg *arg) { 10.74 unsigned int n; 10.75 @@ -299,18 +292,15 @@ 10.76 10.77 if(!sel) 10.78 return; 10.79 - 10.80 if(sel->isfloat || (arrange == dofloat)) { 10.81 togglemax(sel); 10.82 return; 10.83 } 10.84 - 10.85 for(n = 0, c = clients; c; c = c->next) 10.86 if(isvisible(c) && !c->isfloat) 10.87 n++; 10.88 if(n < 2 || (arrange == dofloat)) 10.89 return; 10.90 - 10.91 if((c = sel) == nexttiled(clients)) 10.92 if(!(c = nexttiled(c->next))) 10.93 return;