]> git.corax.cc Git - dwm/commitdiff
Use kernel-style indentation
authorMatthias Kruk <matthias.kruk@miraclelinux.com>
Fri, 12 Mar 2021 23:02:59 +0000 (08:02 +0900)
committerMatthias Kruk <matthias.kruk@miraclelinux.com>
Fri, 12 Mar 2021 23:02:59 +0000 (08:02 +0900)
This changes the code to use kernel-style indentation. This makes the
source longer, but also improves readability, especially with regards
to nesting.

dwm.c

diff --git a/dwm.c b/dwm.c
index e59a415ff5480121cfcd76d4ec9b2cdcbce610b9..d9794f1f10a78597ae0b681386803957f3393029 100755 (executable)
--- a/dwm.c
+++ b/dwm.c
 #include <X11/extensions/Xinerama.h>
 #endif /* XINERAMA */
 
-/* macros */
 #define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
 #define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
 #define INTERSECT(x,y,w,h,m)    (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
-                               * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
+                                * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
 #define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
 #define LENGTH(X)               (sizeof X / sizeof X[0])
 #ifndef MAX
@@ -67,7 +66,6 @@
 #define SYSTEM_TRAY_REQUEST_DOCK    0
 #define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
 
-/* XEMBED messages */
 #define XEMBED_EMBEDDED_NOTIFY      0
 #define XEMBED_WINDOW_ACTIVATE      1
 #define XEMBED_FOCUS_IN             4
 #define VERSION_MINOR               0
 #define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR
 
-/* enums */
-enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
-enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
-enum { NetSupported, NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation,
-          NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType,
-          NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */
-enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
-enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
-enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
-       ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
+enum {
+       CurNormal,
+       CurResize,
+       CurMove,
+       CurLast
+};
+
+enum {
+       ColBorder,
+       ColFG,
+       ColBG,
+       ColLast
+};
+
+/* EWMH atoms */
+enum {
+       NetSupported,
+       NetSystemTray,
+       NetSystemTrayOP,
+       NetSystemTrayOrientation,
+       NetWMName,
+       NetWMState,
+       NetWMFullscreen,
+       NetActiveWindow,
+       NetWMWindowType,
+       NetWMWindowTypeDialog,
+       NetLast
+};
+
+enum {
+       Manager,
+       Xembed,
+       XembedInfo,
+       XLast
+};
+
+enum {
+       WMProtocols,
+       WMDelete,
+       WMState,
+       WMTakeFocus,
+       WMLast
+};
+
+enum {
+       ClkTagBar,
+       ClkLtSymbol,
+       ClkStatusText,
+       ClkWinTitle,
+       ClkClientWin,
+       ClkRootWin,
+       ClkLast
+};
 
 typedef union {
        int i;
@@ -109,6 +150,7 @@ typedef struct {
 
 typedef struct Monitor Monitor;
 typedef struct Client Client;
+
 struct Client {
        char name[256];
        float mina, maxa;
@@ -125,16 +167,22 @@ struct Client {
 };
 
 typedef struct {
-       int x, y, w, h;
+       int x;
+       int y;
+       int w;
+       int h;
+
        unsigned long norm[ColLast];
        unsigned long sel[ColLast];
        Drawable drawable;
        GC gc;
+
        struct {
                XftColor norm[ColLast];
                XftColor sel[ColLast];
                XftDraw *drawable;
        } xft;
+
        struct {
                int ascent;
                int descent;
@@ -160,9 +208,15 @@ struct Monitor {
        float mfact;
        int nmaster;
        int num;
-       int by;               /* bar geometry */
-       int mx, my, mw, mh;   /* screen size */
-       int wx, wy, ww, wh;   /* window area  */
+       int by;
+       int mx;
+       int my;
+       int mw;
+       int mh; /* display area */
+       int wx;
+       int wy;
+       int ww;
+       int wh; /* window area */
        unsigned int seltags;
        unsigned int sellt;
        unsigned int tagset[2];
@@ -199,7 +253,7 @@ static void arrangemon(Monitor *m);
 static void attach(Client *c);
 static void attachstack(Client *c);
 static void buttonpress(XEvent *e);
-static void checkotherwm(void);
+static int checkotherwm(void);
 static void cleanup(void);
 static void cleanupmon(Monitor *mon);
 static void clearurgent(Client *c);
@@ -358,8 +412,8 @@ static Window root;
 struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
 
 /* function implementations */
-void
-applyrules(Client *c) {
+void applyrules(Client *c)
+{
        const char *class, *instance;
        unsigned int i;
        const Rule *r;
@@ -374,126 +428,176 @@ applyrules(Client *c) {
 
        for(i = 0; i < LENGTH(rules); i++) {
                r = &rules[i];
-               if((!r->title || strstr(c->name, r->title))
-               && (!r->class || strstr(class, r->class))
-               && (!r->instance || strstr(instance, r->instance)))
-               {
+
+               if((!r->title || strstr(c->name, r->title)) &&
+                  (!r->class || strstr(class, r->class)) &&
+                  (!r->instance || strstr(instance, r->instance))) {
                        c->isfloating = r->isfloating;
                        c->tags |= r->tags;
+
                        for(m = mons; m && m->num != r->monitor; m = m->next);
-                       if(m)
+
+                       if(m) {
                                c->mon = m;
+                       }
                }
        }
-       if(ch.res_class)
+
+       if(ch.res_class) {
                XFree(ch.res_class);
-       if(ch.res_name)
+       }
+
+       if(ch.res_name) {
                XFree(ch.res_name);
+       }
+
        c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
+
+       return;
 }
 
-Bool
-applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) {
+Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact)
+{
        Bool baseismin;
        Monitor *m = c->mon;
 
        /* set minimum possible */
        *w = MAX(1, *w);
        *h = MAX(1, *h);
+
        if(interact) {
-               if(*x > sw)
+               if(*x > sw) {
                        *x = sw - WIDTH(c);
-               if(*y > sh)
+               }
+               if(*y > sh) {
                        *y = sh - HEIGHT(c);
-               if(*x + *w + 2 * c->bw < 0)
+               }
+               if(*x + *w + 2 * c->bw < 0) {
                        *x = 0;
-               if(*y + *h + 2 * c->bw < 0)
+               }
+               if(*y + *h + 2 * c->bw < 0) {
                        *y = 0;
-       }
-       else {
-               if(*x >= m->wx + m->ww)
+               }
+       else {
+               if(*x >= m->wx + m->ww) {
                        *x = m->wx + m->ww - WIDTH(c);
-               if(*y >= m->wy + m->wh)
+               }
+               if(*y >= m->wy + m->wh) {
                        *y = m->wy + m->wh - HEIGHT(c);
-               if(*x + *w + 2 * c->bw <= m->wx)
+               }
+               if(*x + *w + 2 * c->bw <= m->wx) {
                        *x = m->wx;
-               if(*y + *h + 2 * c->bw <= m->wy)
+               }
+               if(*y + *h + 2 * c->bw <= m->wy) {
                        *y = m->wy;
+               }
        }
-       if(*h < bh)
+
+       if(*h < bh) {
                *h = bh;
-       if(*w < bh)
+       }
+       if(*w < bh) {
                *w = bh;
+       }
+
        if(resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
                /* see last two sentences in ICCCM 4.1.2.3 */
                baseismin = c->basew == c->minw && c->baseh == c->minh;
+
                if(!baseismin) { /* temporarily remove base dimensions */
                        *w -= c->basew;
                        *h -= c->baseh;
                }
+
                /* adjust for aspect limits */
                if(c->mina > 0 && c->maxa > 0) {
-                       if(c->maxa < (float)*w / *h)
+                       if(c->maxa < (float)*w / *h) {
                                *w = *h * c->maxa + 0.5;
-                       else if(c->mina < (float)*h / *w)
+                       } else if(c->mina < (float)*h / *w) {
                                *h = *w * c->mina + 0.5;
+                       }
                }
+
                if(baseismin) { /* increment calculation requires this */
                        *w -= c->basew;
                        *h -= c->baseh;
                }
+
                /* adjust for increment value */
-               if(c->incw)
+               if(c->incw) {
                        *w -= *w % c->incw;
-               if(c->inch)
+               }
+               if(c->inch) {
                        *h -= *h % c->inch;
+               }
 
                /* restore base dimensions */
                *w = MAX(*w + c->basew, c->minw);
                *h = MAX(*h + c->baseh, c->minh);
 
-               if(c->maxw)
+               if(c->maxw) {
                        *w = MIN(*w, c->maxw);
-               if(c->maxh)
+               }
+               if(c->maxh) {
                        *h = MIN(*h, c->maxh);
+               }
        }
-       return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
+
+       return(*x != c->x || *y != c->y || *w != c->w || *h != c->h);
 }
 
-void
-arrange(Monitor *m) {
-       if(m)
-               showhide(m->stack);
-       else for(m = mons; m; m = m->next)
+void arrange(Monitor *m)
+{
+       if(m) {
                showhide(m->stack);
-       if(m)
-               arrangemon(m);
-       else for(m = mons; m; m = m->next)
+       } else {
+               for(m = mons; m; m = m->next) {
+                       showhide(m->stack);
+               }
+       }
+
+       if(m) {
                arrangemon(m);
+       } else {
+               for(m = mons; m; m = m->next) {
+                       arrangemon(m);
+               }
+       }
+
+       return;
 }
 
-void
-arrangemon(Monitor *m) {
+void arrangemon(Monitor *m)
+{
        strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
-       if(m->lt[m->sellt]->arrange)
+
+       if(m->lt[m->sellt]->arrange) {
                m->lt[m->sellt]->arrange(m);
+       }
+
        restack(m);
+
+       return;
 }
 
-void
-attach(Client *c) {
+void attach(Client *c)
+{
        c->next = c->mon->clients;
        c->mon->clients = c;
+
+       return;
 }
 
-void
-attachstack(Client *c) {
+void attachstack(Client *c)
+{
        c->snext = c->mon->stack;
        c->mon->stack = c;
+
+       return;
 }
 
-void
-buttonpress(XEvent *e) {
+void buttonpress(XEvent *e)
+{
        unsigned int i, x, click;
        Arg arg = {0};
        Client *c;
@@ -501,50 +605,65 @@ buttonpress(XEvent *e) {
        XButtonPressedEvent *ev = &e->xbutton;
 
        click = ClkRootWin;
+
        /* focus monitor if necessary */
        if((m = wintomon(ev->window)) && m != selmon) {
                unfocus(selmon->sel, True);
                selmon = m;
                focus(NULL);
        }
+
        if(ev->window == selmon->barwin) {
                i = x = 0;
-               do
+
+               do {
                        x += TEXTW(tags[i]);
-               while(ev->x >= x && ++i < LENGTH(tags));
+               } while(ev->x >= x && ++i < LENGTH(tags));
+
                if(i < LENGTH(tags)) {
                        click = ClkTagBar;
                        arg.ui = 1 << i;
-               }
-               else if(ev->x < x + blw)
+               } else if(ev->x < x + blw) {
                        click = ClkLtSymbol;
-               else if(ev->x > selmon->ww - TEXTW(stext))
+               } else if(ev->x > selmon->ww - TEXTW(stext)) {
                        click = ClkStatusText;
-               else
+               } else {
                        click = ClkWinTitle;
-       }
-       else if((c = wintoclient(ev->window))) {
+               }
+       else if((c = wintoclient(ev->window))) {
                focus(c);
                click = ClkClientWin;
        }
-       for(i = 0; i < LENGTH(buttons); i++)
+
+       for(i = 0; i < LENGTH(buttons); i++) {
                if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
-               && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
+                  && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) {
                        buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
+               }
+       }
+
+       return;
 }
 
-void
-checkotherwm(void) {
+int checkotherwm(void)
+{
        xerrorxlib = XSetErrorHandler(xerrorstart);
+
+       if(!xerrorxlib) {
+               return(-EIO);
+       }
+
        /* this causes an error if some other window manager is running */
        XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
        XSync(dpy, False);
        XSetErrorHandler(xerror);
        XSync(dpy, False);
+
+       return(0);
 }
 
-void
-cleanup(void) {
+void cleanup(void)
+{
        Arg a = {.ui = ~0};
        Layout foo = { "", NULL };
        Monitor *m;
@@ -578,8 +697,8 @@ cleanup(void) {
        XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
 }
 
-void
-cleanupmon(Monitor *mon) {
+void cleanupmon(Monitor *mon)
+{
        Monitor *m;
 
        if(mon == mons)
@@ -593,8 +712,8 @@ cleanupmon(Monitor *mon) {
        free(mon);
 }
 
-void
-clearurgent(Client *c) {
+void clearurgent(Client *c)
+{
        XWMHints *wmh;
 
        c->isurgent = False;
@@ -605,8 +724,8 @@ clearurgent(Client *c) {
        XFree(wmh);
 }
 
-void
-clientmessage(XEvent *e) {
+void clientmessage(XEvent *e)
+{
        XWindowAttributes wa;
        XSetWindowAttributes swa;
        XClientMessageEvent *cme = &e->xclient;
@@ -639,35 +758,45 @@ clientmessage(XEvent *e) {
                        swa.background_pixmap = ParentRelative;
                        swa.background_pixel  = dc.norm[ColBG];
                        XChangeWindowAttributes(dpy, c->win, CWBackPixmap|CWBackPixel, &swa);
-                       sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
+                       sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime,
+                                 XEMBED_EMBEDDED_NOTIFY, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
                        /* FIXME not sure if I have to send these events, too */
-                       sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_FOCUS_IN, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
-                       sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
-                       sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_MODALITY_ON, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
+                       sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime,
+                                 XEMBED_FOCUS_IN, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
+                       sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime,
+                                 XEMBED_WINDOW_ACTIVATE, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
+                       sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime,
+                                 XEMBED_MODALITY_ON, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
                        resizebarwin(selmon);
                        updatesystray();
                        setclientstate(c, NormalState);
                }
+
                return;
        }
-       if(!c)
+
+       if(!c) {
                return;
+       }
+
        if(cme->message_type == netatom[NetWMState]) {
-               if(cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen])
+               if(cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen]) {
                        setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD    */
-                                     || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
-       }
-       else if(cme->message_type == netatom[NetActiveWindow]) {
+                                         || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
+               }
+       else if(cme->message_type == netatom[NetActiveWindow]) {
                if(!ISVISIBLE(c)) {
                        c->mon->seltags ^= 1;
                        c->mon->tagset[c->mon->seltags] = c->tags;
                }
                pop(c);
        }
+
+       return;
 }
 
-void
-configure(Client *c) {
+void configure(Client *c)
+{
        XConfigureEvent ce;
 
        ce.type = ConfigureNotify;
@@ -682,10 +811,12 @@ configure(Client *c) {
        ce.above = None;
        ce.override_redirect = False;
        XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
+
+       return;
 }
 
-void
-configurenotify(XEvent *e) {
+void configurenotify(XEvent *e)
+{
        Monitor *m;
        XConfigureEvent *ev = &e->xconfigure;
        Bool dirty;
@@ -694,32 +825,41 @@ configurenotify(XEvent *e) {
                dirty = (sw != ev->width);
                sw = ev->width;
                sh = ev->height;
+
                if(updategeom() || dirty) {
-                       if(dc.drawable != 0)
+                       if(dc.drawable != 0) {
                                XFreePixmap(dpy, dc.drawable);
+                       }
+
                        dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
                        XftDrawChange(dc.xft.drawable, dc.drawable);
                        updatebars();
-                       for(m = mons; m; m = m->next)
+
+                       for(m = mons; m; m = m->next) {
                                resizebarwin(m);
+                       }
+
                        focus(NULL);
                        arrange(NULL);
                }
        }
+
+       return;
 }
 
-void
-configurerequest(XEvent *e) {
+void configurerequest(XEvent *e)
+{
        Client *c;
        Monitor *m;
        XConfigureRequestEvent *ev = &e->xconfigurerequest;
        XWindowChanges wc;
 
        if((c = wintoclient(ev->window))) {
-               if(ev->value_mask & CWBorderWidth)
+               if(ev->value_mask & CWBorderWidth) {
                        c->bw = ev->border_width;
-               else if(c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
+               else if(c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
                        m = c->mon;
+
                        if(ev->value_mask & CWX) {
                                c->oldx = c->x;
                                c->x = m->mx + ev->x;
@@ -736,19 +876,24 @@ configurerequest(XEvent *e) {
                                c->oldh = c->h;
                                c->h = ev->height;
                        }
-                       if((c->x + c->w) > m->mx + m->mw && c->isfloating)
+
+                       if((c->x + c->w) > m->mx + m->mw && c->isfloating) {
                                c->x = m->mx + (m->mw / 2 - WIDTH(c) / 2); /* center in x direction */
-                       if((c->y + c->h) > m->my + m->mh && c->isfloating)
+                       }
+                       if((c->y + c->h) > m->my + m->mh && c->isfloating) {
                                c->y = m->my + (m->mh / 2 - HEIGHT(c) / 2); /* center in y direction */
-                       if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
+                       }
+                       if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight))) {
                                configure(c);
-                       if(ISVISIBLE(c))
+                       }
+
+                       if(ISVISIBLE(c)) {
                                XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
-               }
-               else
+                       }
+               } else {
                        configure(c);
-       }
-       else {
+               }
+       else {
                wc.x = ev->x;
                wc.y = ev->y;
                wc.width = ev->width;
@@ -758,15 +903,20 @@ configurerequest(XEvent *e) {
                wc.stack_mode = ev->detail;
                XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
        }
+
        XSync(dpy, False);
+
+       return;
 }
 
-Monitor *
-createmon(void) {
+Monitor *createmon(void)
+{
        Monitor *m;
 
-       if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
+       if(!(m = (Monitor *)calloc(1, sizeof(Monitor)))) {
                die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
+       }
+
        m->tagset[0] = m->tagset[1] = 1;
        m->mfact = mfact;
        m->nmaster = nmaster;
@@ -775,33 +925,38 @@ createmon(void) {
        m->lt[0] = &layouts[0];
        m->lt[1] = &layouts[1 % LENGTH(layouts)];
        strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
-       return m;
+
+       return(m);
 }
 
-void
-destroynotify(XEvent *e) {
+void destroynotify(XEvent *e)
+{
        Client *c;
        XDestroyWindowEvent *ev = &e->xdestroywindow;
 
-       if((c = wintoclient(ev->window)))
+       if((c = wintoclient(ev->window))) {
                unmanage(c, True);
-       else if((c = wintosystrayicon(ev->window))) {
+       else if((c = wintosystrayicon(ev->window))) {
                removesystrayicon(c);
                resizebarwin(selmon);
                updatesystray();
        }
+
+       return;
 }
 
-void
-detach(Client *c) {
+void detach(Client *c)
+{
        Client **tc;
 
        for(tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
        *tc = c->next;
+
+       return;
 }
 
-void
-detachstack(Client *c) {
+void detachstack(Client *c)
+{
        Client **tc, *t;
 
        for(tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext);
@@ -811,47 +966,57 @@ detachstack(Client *c) {
                for(t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext);
                c->mon->sel = t;
        }
+
+       return;
 }
 
-void
-die(const char *errstr, ...) {
+void die(const char *errstr, ...)
+{
        va_list ap;
 
        va_start(ap, errstr);
        vfprintf(stderr, errstr, ap);
        va_end(ap);
        exit(EXIT_FAILURE);
+
+       return;
 }
 
-Monitor *
-dirtomon(int dir) {
+Monitor *dirtomon(int dir)
+{
        Monitor *m = NULL;
 
        if(dir > 0) {
                if(!(m = selmon->next))
                        m = mons;
-       }
-       else if(selmon == mons)
+       } else if(selmon == mons) {
                for(m = mons; m->next; m = m->next);
-       else
+       } else {
                for(m = mons; m->next != selmon; m = m->next);
-       return m;
+       }
+
+       return(m);
 }
 
-void
-drawbar(Monitor *m) {
+void drawbar(Monitor *m)
+{
        int x;
        unsigned int i, occ = 0, urg = 0;
        unsigned long *col;
        Client *c;
 
        resizebarwin(m);
+
        for(c = m->clients; c; c = c->next) {
                occ |= c->tags;
-               if(c->isurgent)
+
+               if(c->isurgent) {
                        urg |= c->tags;
+               }
        }
+
        dc.x = 0;
+
        for(i = 0; i < LENGTH(tags); i++) {
                dc.w = TEXTW(tags[i]);
                col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
@@ -860,6 +1025,7 @@ drawbar(Monitor *m) {
                           occ & 1 << i, urg & 1 << i, col);
                dc.x += dc.w;
        }
+
        dc.w = blw = TEXTW(m->ltsymbol);
        drawtext(m->ltsymbol, dc.norm, False);
        dc.x += dc.w;
@@ -867,185 +1033,256 @@ drawbar(Monitor *m) {
 
        dc.w = TEXTW(stext);
        dc.x = m->ww - dc.w;
+
        if(showsystray && m == selmon) {
                dc.x -= getsystraywidth();
        }
+
        if(dc.x < x) {
                dc.x = x;
                dc.w = m->ww - x;
        }
+
        drawtext(stext, dc.norm, False);
 
        if((dc.w = dc.x - x) > bh) {
                dc.x = x;
+
                if(m->sel) {
                        col = m == selmon ? dc.sel : dc.norm;
                        /* drawtext(m->sel->name, col, False); */
                        drawsquare(m->sel->isfixed, m->sel->isfloating, False, col);
-               }
-               else
+               } else {
                        drawtext(NULL, dc.norm, False);
+               }
        }
+
        XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
        XSync(dpy, False);
+
+       return;
 }
 
-void
-drawbars(void) {
+void drawbars(void)
+{
        Monitor *m;
 
-       for(m = mons; m; m = m->next)
+       for(m = mons; m; m = m->next) {
                drawbar(m);
+       }
+
        updatesystray();
+
+       return;
 }
 
-void
-drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
+void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast])
+{
        int x;
 
        XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
        x = (dc.font.ascent + dc.font.descent + 2) / 4;
-       if(filled)
+       if(filled) {
                XFillRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x+1, x+1);
-       else if(empty)
+       } else if(empty) {
                XDrawRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x, x);
+       }
+
+       return;
 }
 
-void
-drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
+void drawtext(const char *text, unsigned long col[ColLast], Bool invert)
+{
        char buf[512];
        int i, x, y, h, len, olen;
 
        XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
        XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
-       if(!text)
+
+       if(!text) {
                return;
+       }
+
        olen = strlen(text);
        h = dc.font.ascent + dc.font.descent;
        y = dc.y + (dc.h / 2) - (h / 2);
        x = dc.x + (h / 2);
+
        /* shorten text if necessary (this could wreak havoc with pango markup but fortunately
           dc.w is adjusted to the width of the status text and not the other way around) */
        for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
-       if(!len)
+
+       if(!len) {
                return;
+       }
+
        memcpy(buf, text, len);
-       if(len < olen)
+
+       if(len < olen) {
                for(i = len; i && i > len - 3; buf[--i] = '.');
-       if(text == stext && statusmarkup)
+       }
+
+       if(text == stext && statusmarkup) {
                pango_layout_set_markup(dc.font.layout, buf, len);
-       else
+       } else {
                pango_layout_set_text(dc.font.layout, buf, len);
+       }
+
        pango_xft_render_layout(dc.xft.drawable,
-               (col == dc.norm ? dc.xft.norm : dc.xft.sel) + (invert ? ColBG : ColFG),
-               dc.font.layout, x * PANGO_SCALE, y * PANGO_SCALE);
-       if(text == stext && statusmarkup) /* clear markup attributes */
+                               (col == dc.norm ? dc.xft.norm : dc.xft.sel) + (invert ? ColBG : ColFG),
+                               dc.font.layout, x * PANGO_SCALE, y * PANGO_SCALE);
+       if(text == stext && statusmarkup) {
+               /* clear markup attributes */
                pango_layout_set_attributes(dc.font.layout, NULL);
+       }
+
+       return;
 }
 
 #ifndef M10K
-void
-enternotify(XEvent *e) {
+void enternotify(XEvent *e)
+{
        Client *c;
        Monitor *m;
        XCrossingEvent *ev = &e->xcrossing;
 
-       if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
+       if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) {
                return;
+       }
+
        c = wintoclient(ev->window);
        m = c ? c->mon : wintomon(ev->window);
+
        if(m != selmon) {
                unfocus(selmon->sel, True);
                selmon = m;
-       }
-       else if(!c || c == selmon->sel)
+       } else if(!c || c == selmon->sel) {
                return;
+       }
+
        focus(c);
+
+       return;
 }
 #endif /* ! M10K */
 
-void
-expose(XEvent *e) {
+void expose(XEvent *e)
+{
        Monitor *m;
        XExposeEvent *ev = &e->xexpose;
 
-       if(ev->count == 0 && (m = wintomon(ev->window)))
+       if(ev->count == 0 && (m = wintomon(ev->window))) {
                drawbar(m);
+       }
+
+       return;
 }
 
-void
-focus(Client *c) {
-       if(!c || !ISVISIBLE(c))
+void focus(Client *c)
+{
+       if(!c || !ISVISIBLE(c)) {
                for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
+       }
+
        /* was if(selmon->sel) */
-       if(selmon->sel && selmon->sel != c)
+       if(selmon->sel && selmon->sel != c) {
                unfocus(selmon->sel, False);
+       }
+
        if(c) {
-               if(c->mon != selmon)
+               if(c->mon != selmon) {
                        selmon = c->mon;
-               if(c->isurgent)
+               }
+
+               if(c->isurgent) {
                        clearurgent(c);
+               }
+
                detachstack(c);
                attachstack(c);
                grabbuttons(c, True);
                XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
                setfocus(c);
-       }
-       else
+       } else {
                XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+       }
+
        selmon->sel = c;
        drawbars();
+
+       return;
 }
 
-void
-focusin(XEvent *e) { /* there are some broken focus acquiring clients */
+void focusin(XEvent *e)
+{
+       /* there are some broken focus acquiring clients */
        XFocusChangeEvent *ev = &e->xfocus;
 
-       if(selmon->sel && ev->window != selmon->sel->win)
+       if(selmon->sel && ev->window != selmon->sel->win) {
                setfocus(selmon->sel);
+       }
+
+       return;
 }
 
-void
-focusmon(const Arg *arg) {
+void focusmon(const Arg *arg)
+{
        Monitor *m;
 
-       if(!mons->next)
+       if(!mons->next) {
                return;
-       if((m = dirtomon(arg->i)) == selmon)
+       }
+
+       if((m = dirtomon(arg->i)) == selmon) {
                return;
+       }
+
        unfocus(selmon->sel, True);
        selmon = m;
        focus(NULL);
+
+       return;
 }
 
-void
-focusstack(const Arg *arg) {
+void focusstack(const Arg *arg)
+{
        Client *c = NULL, *i;
 
-       if(!selmon->sel)
+       if(!selmon->sel) {
                return;
+       }
+
        if(arg->i > 0) {
                for(c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
-               if(!c)
+               if(!c) {
                        for(c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
-       }
-       else {
-               for(i = selmon->clients; i != selmon->sel; i = i->next)
-                       if(ISVISIBLE(i))
+               }
+       else {
+               for(i = selmon->clients; i != selmon->sel; i = i->next) {
+                       if(ISVISIBLE(i)) {
                                c = i;
-               if(!c)
-                       for(; i; i = i->next)
-                               if(ISVISIBLE(i))
+                       }
+               }
+
+               if(!c) {
+                       for(; i; i = i->next) {
+                               if(ISVISIBLE(i)) {
                                        c = i;
+                               }
+                       }
+               }
        }
+
        if(c) {
                focus(c);
                restack(selmon);
        }
+
+       return;
 }
 
-Atom
-getatomprop(Client *c, Atom prop) {
+Atom getatomprop(Client *c, Atom prop)
+{
        int di;
        unsigned long dl;
        unsigned char *p = NULL;
@@ -1053,40 +1290,48 @@ getatomprop(Client *c, Atom prop) {
        /* FIXME getatomprop should return the number of items and a pointer to
         * the stored data instead of this workaround */
        Atom req = XA_ATOM;
-       if(prop == xatom[XembedInfo])
+
+       if(prop == xatom[XembedInfo]) {
                req = xatom[XembedInfo];
+       }
 
        if(XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, req,
                              &da, &di, &dl, &dl, &p) == Success && p) {
                atom = *(Atom *)p;
-               if(da == xatom[XembedInfo] && dl == 2)
+
+               if(da == xatom[XembedInfo] && dl == 2) {
                        atom = ((Atom *)p)[1];
+               }
+
                XFree(p);
        }
-       return atom;
+
+       return(atom);
 }
 
-unsigned long
-getcolor(const char *colstr, XftColor *color) {
+unsigned long getcolor(const char *colstr, XftColor *color)
+{
        Colormap cmap = DefaultColormap(dpy, screen);
        Visual *vis = DefaultVisual(dpy, screen);
 
-       if(!XftColorAllocName(dpy, vis, cmap, colstr, color))
+       if(!XftColorAllocName(dpy, vis, cmap, colstr, color)) {
                die("error, cannot allocate color '%s'\n", colstr);
-       return color->pixel;
+       }
+
+       return(color->pixel);
 }
 
-Bool
-getrootptr(int *x, int *y) {
+Bool getrootptr(int *x, int *y)
+{
        int di;
        unsigned int dui;
        Window dummy;
 
-       return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
+       return(XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui));
 }
 
-long
-getstate(Window w) {
+long getstate(Window w)
+{
        int format;
        long result = -1;
        unsigned char *p = NULL;
@@ -1094,25 +1339,32 @@ getstate(Window w) {
        Atom real;
 
        if(XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
-                             &real, &format, &n, &extra, (unsigned char **)&p) != Success)
+                             &real, &format, &n, &extra, (unsigned char **)&p) != Success) {
                return -1;
-       if(n != 0)
+       }
+
+       if(n != 0) {
                result = *p;
+       }
+
        XFree(p);
-       return result;
+
+       return(result);
 }
 
-unsigned int
-getsystraywidth() {
+unsigned int getsystraywidth(void)
+{
        unsigned int w = 0;
        Client *i;
-       if(showsystray)
+       if(showsystray) {
                for(i = systray->icons; i; w += i->w + systrayspacing, i = i->next) ;
-       return w ? w + systrayspacing : 1;
+       }
+
+       return(w ? w + systrayspacing : 1);
 }
 
-Bool
-gettextprop(Window w, Atom atom, char *text, unsigned int size) {
+Bool gettextprop(Window w, Atom atom, char *text, unsigned int size)
+{
        char **list = NULL;
        int n;
        XTextProperty name;
@@ -1133,33 +1385,39 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
        }
        text[size - 1] = '\0';
        XFree(name.value);
-       return True;
+
+       return(True);
 }
 
-void
-grabbuttons(Client *c, Bool focused) {
+void grabbuttons(Client *c, Bool focused)
+{
        updatenumlockmask();
        {
                unsigned int i, j;
                unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
                XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
                if(focused) {
-                       for(i = 0; i < LENGTH(buttons); i++)
-                               if(buttons[i].click == ClkClientWin)
-                                       for(j = 0; j < LENGTH(modifiers); j++)
+                       for(i = 0; i < LENGTH(buttons); i++) {
+                               if(buttons[i].click == ClkClientWin) {
+                                       for(j = 0; j < LENGTH(modifiers); j++) {
                                                XGrabButton(dpy, buttons[i].button,
                                                            buttons[i].mask | modifiers[j],
                                                            c->win, False, BUTTONMASK,
                                                            GrabModeAsync, GrabModeSync, None, None);
-               }
-               else
+                                       }
+                               }
+                       }
+               } else {
                        XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
                                    BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
+               }
        }
+
+       return;
 }
 
-void
-grabkeys(void) {
+void grabkeys(void)
+{
        updatenumlockmask();
        {
                unsigned int i, j;
@@ -1167,22 +1425,29 @@ grabkeys(void) {
                KeyCode code;
 
                XUngrabKey(dpy, AnyKey, AnyModifier, root);
-               for(i = 0; i < LENGTH(keys); i++)
-                       if((code = XKeysymToKeycode(dpy, keys[i].keysym)))
-                               for(j = 0; j < LENGTH(modifiers); j++)
+               for(i = 0; i < LENGTH(keys); i++) {
+                       if((code = XKeysymToKeycode(dpy, keys[i].keysym))) {
+                               for(j = 0; j < LENGTH(modifiers); j++) {
                                        XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
                                                 True, GrabModeAsync, GrabModeAsync);
+                               }
+                       }
+               }
        }
+
+       return;
 }
 
-void
-incnmaster(const Arg *arg) {
+void incnmaster(const Arg *arg)
+{
        selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
        arrange(selmon);
+
+       return;
 }
 
-void
-initfont(const char *fontstr) {
+void initfont(const char *fontstr)
+{
        PangoFontMap *fontmap;
        PangoContext *context;
        PangoFontDescription *desc;
@@ -1201,39 +1466,48 @@ initfont(const char *fontstr) {
 
        pango_font_metrics_unref(metrics);
        g_object_unref(context);
+
+       return;
 }
 
 #ifdef XINERAMA
-static Bool
-isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) {
-       while(n--)
+static Bool isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
+{
+       while(n--) {
                if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org
-               && unique[n].width == info->width && unique[n].height == info->height)
-                       return False;
-       return True;
+                  && unique[n].width == info->width && unique[n].height == info->height) {
+                       return(False);
+               }
+       }
+
+       return(True);
 }
 #endif /* XINERAMA */
 
-void
-keypress(XEvent *e) {
+void keypress(XEvent *e)
+{
        unsigned int i;
        KeySym keysym;
        XKeyEvent *ev;
 
        ev = &e->xkey;
        keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
-       for(i = 0; i < LENGTH(keys); i++)
+       for(i = 0; i < LENGTH(keys); i++) {
                if(keysym == keys[i].keysym
-               && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
-               && keys[i].func)
+                  && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
+                  && keys[i].func) {
                        keys[i].func(&(keys[i].arg));
+               }
+       }
+
+       return;
 }
 
-void
-killclient(const Arg *arg) {
-       if(!selmon->sel)
-               return;
-       if(!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0 , 0, 0)) {
+void killclient(const Arg *arg)
+{
+       if(selmon->sel && !sendevent(selmon->sel->win, wmatom[WMDelete],
+                                    NoEventMask, wmatom[WMDelete],
+                                    CurrentTime, 0 , 0, 0)) {
                XGrabServer(dpy);
                XSetErrorHandler(xerrordummy);
                XSetCloseDownMode(dpy, DestroyAll);
@@ -1242,26 +1516,31 @@ killclient(const Arg *arg) {
                XSetErrorHandler(xerror);
                XUngrabServer(dpy);
        }
+
+       return;
 }
 
-void
-manage(Window w, XWindowAttributes *wa) {
+void manage(Window w, XWindowAttributes *wa)
+{
        Client *c, *t = NULL;
        Window trans = None;
        XWindowChanges wc;
 
-       if(!(c = calloc(1, sizeof(Client))))
+       if(!(c = calloc(1, sizeof(Client)))) {
                die("fatal: could not malloc() %u bytes\n", sizeof(Client));
+       }
+
        c->win = w;
        updatetitle(c);
+
        if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
                c->mon = t->mon;
                c->tags = t->tags;
-       }
-       else {
+       } else {
                c->mon = selmon;
                applyrules(c);
        }
+
        /* geometry */
        c->x = c->oldx = wa->x;
        c->y = c->oldy = wa->y;
@@ -1269,14 +1548,16 @@ manage(Window w, XWindowAttributes *wa) {
        c->h = c->oldh = wa->height;
        c->oldbw = wa->border_width;
 
-       if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
+       if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw) {
                c->x = c->mon->mx + c->mon->mw - WIDTH(c);
-       if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh)
+       }
+       if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh) {
                c->y = c->mon->my + c->mon->mh - HEIGHT(c);
+       }
        c->x = MAX(c->x, c->mon->mx);
        /* only fix client y-offset, if the client center might cover the bar */
        c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
-                  && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
+                         && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
        c->bw = borderpx;
 
        wc.border_width = c->bw;
@@ -1302,82 +1583,104 @@ manage(Window w, XWindowAttributes *wa) {
        arrange(c->mon);
        XMapWindow(dpy, c->win);
        focus(NULL);
+
+       return;
 }
 
-void
-mappingnotify(XEvent *e) {
+void mappingnotify(XEvent *e)
+{
        XMappingEvent *ev = &e->xmapping;
 
        XRefreshKeyboardMapping(ev);
-       if(ev->request == MappingKeyboard)
+       if(ev->request == MappingKeyboard) {
                grabkeys();
+       }
+
+       return;
 }
 
-void
-maprequest(XEvent *e) {
+void maprequest(XEvent *e)
+{
        static XWindowAttributes wa;
        XMapRequestEvent *ev = &e->xmaprequest;
        Client *i;
+
        if((i = wintosystrayicon(ev->window))) {
-               sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION);
+               sendevent(i->win, netatom[Xembed], StructureNotifyMask,
+                         CurrentTime, XEMBED_WINDOW_ACTIVATE, 0,
+                         systray->win, XEMBED_EMBEDDED_VERSION);
                resizebarwin(selmon);
                updatesystray();
        }
 
-       if(!XGetWindowAttributes(dpy, ev->window, &wa))
-               return;
-       if(wa.override_redirect)
-               return;
-       if(!wintoclient(ev->window))
-               manage(ev->window, &wa);
+       if(XGetWindowAttributes(dpy, ev->window, &wa) && !wa.override_redirect) {
+               if(!wintoclient(ev->window)) {
+                       manage(ev->window, &wa);
+               }
+       }
+
+       return;
 }
 
-void
-monocle(Monitor *m) {
+void monocle(Monitor *m)
+{
        unsigned int n = 0;
        Client *c;
 
-       for(c = m->clients; c; c = c->next)
-               if(ISVISIBLE(c))
+       for(c = m->clients; c; c = c->next) {
+               if(ISVISIBLE(c)) {
                        n++;
-       if(n > 0) /* override layout symbol */
+               }
+       }
+
+       if(n > 0) { /* override layout symbol */
                snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
-       for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
+       }
+
+       for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
                resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
+       }
+
+       return;
 }
 
 #ifndef M10K
-void
-motionnotify(XEvent *e) {
+void motionnotify(XEvent *e)
+{
        static Monitor *mon = NULL;
        Monitor *m;
        XMotionEvent *ev = &e->xmotion;
 
-       if(ev->window != root)
+       if(ev->window != root) {
                return;
+       }
+
        if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
                selmon = m;
                focus(NULL);
        }
+
        mon = m;
        return;
 }
 #endif /* ! M10K */
 
-void
-movemouse(const Arg *arg) {
+void movemouse(const Arg *arg)
+{
        int x, y, ocx, ocy, nx, ny;
        Client *c;
        Monitor *m;
        XEvent ev;
 
-       if(!(c = selmon->sel))
+       if(!(c = selmon->sel)) {
                return;
+       }
+
        restack(selmon);
        ocx = c->x;
        ocy = c->y;
        if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
-       None, cursor[CurMove], CurrentTime) != GrabSuccess)
+                       None, cursor[CurMove], CurrentTime) != GrabSuccess)
                return;
        if(!getrootptr(&x, &y))
                return;
@@ -1393,7 +1696,7 @@ movemouse(const Arg *arg) {
                        nx = ocx + (ev.xmotion.x - x);
                        ny = ocy + (ev.xmotion.y - y);
                        if(nx >= selmon->wx && nx <= selmon->wx + selmon->ww
-                       && ny >= selmon->wy && ny <= selmon->wy + selmon->wh) {
+                          && ny >= selmon->wy && ny <= selmon->wy + selmon->wh) {
                                if(abs(selmon->wx - nx) < snap)
                                        nx = selmon->wx;
                                else if(abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
@@ -1403,7 +1706,7 @@ movemouse(const Arg *arg) {
                                else if(abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
                                        ny = selmon->wy + selmon->wh - HEIGHT(c);
                                if(!c->isfloating && selmon->lt[selmon->sellt]->arrange
-                               && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
+                                  && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
                                        togglefloating(NULL);
                        }
                        if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
@@ -1417,24 +1720,29 @@ movemouse(const Arg *arg) {
                selmon = m;
                focus(NULL);
        }
+
+       return;
 }
 
-Client *
-nexttiled(Client *c) {
+Client *nexttiled(Client *c)
+{
        for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
-       return c;
+
+       return(c);
 }
 
-void
-pop(Client *c) {
+void pop(Client *c)
+{
        detach(c);
        attach(c);
        focus(c);
        arrange(c->mon);
+
+       return;
 }
 
-void
-propertynotify(XEvent *e) {
+void propertynotify(XEvent *e)
+{
        Client *c;
        Window trans;
        XPropertyEvent *ev = &e->xproperty;
@@ -1477,55 +1785,74 @@ propertynotify(XEvent *e) {
                if(ev->atom == netatom[NetWMWindowType])
                        updatewindowtype(c);
        }
+
+       return;
 }
 
-void
-quit(const Arg *arg) {
+void quit(const Arg *arg)
+{
        running = False;
+       return;
 }
 
-Monitor *
-recttomon(int x, int y, int w, int h) {
+Monitor *recttomon(int x, int y, int w, int h)
+{
        Monitor *m, *r = selmon;
        int a, area = 0;
 
-       for(m = mons; m; m = m->next)
+       for(m = mons; m; m = m->next) {
                if((a = INTERSECT(x, y, w, h, m)) > area) {
                        area = a;
                        r = m;
                }
-       return r;
+       }
+
+       return(r);
 }
 
-void
-removesystrayicon(Client *i) {
+void removesystrayicon(Client *i)
+{
        Client **ii;
 
-       if(!showsystray || !i)
+       if(!showsystray || !i) {
                return;
+       }
+
        for(ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next);
-       if(ii)
+
+       if(ii) {
                *ii = i->next;
+       }
+
        free(i);
+       return;
 }
 
 
-void
-resize(Client *c, int x, int y, int w, int h, Bool interact) {
-       if(applysizehints(c, &x, &y, &w, &h, interact))
+void resize(Client *c, int x, int y, int w, int h, Bool interact)
+{
+       if(applysizehints(c, &x, &y, &w, &h, interact)) {
                resizeclient(c, x, y, w, h);
+       }
+
+       return;
 }
 
-void
-resizebarwin(Monitor *m) {
+void resizebarwin(Monitor *m)
+{
        unsigned int w = m->ww;
-       if(showsystray && m == selmon)
+
+       if(showsystray && m == selmon) {
                w -= getsystraywidth();
+       }
+
        XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh);
+
+       return;
 }
 
-void
-resizeclient(Client *c, int x, int y, int w, int h) {
+void resizeclient(Client *c, int x, int y, int w, int h)
+{
        XWindowChanges wc;
 
        c->oldx = c->x; c->x = wc.x = x;
@@ -1537,25 +1864,33 @@ resizeclient(Client *c, int x, int y, int w, int h) {
        XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
        configure(c);
        XSync(dpy, False);
+
+       return;
 }
 
-void
-resizemouse(const Arg *arg) {
+void resizemouse(const Arg *arg)
+{
        int ocx, ocy;
        int nw, nh;
        Client *c;
        Monitor *m;
        XEvent ev;
 
-       if(!(c = selmon->sel))
+       if(!(c = selmon->sel)) {
                return;
+       }
+
        restack(selmon);
        ocx = c->x;
        ocy = c->y;
+
        if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
-                       None, cursor[CurResize], CurrentTime) != GrabSuccess)
+                       None, cursor[CurResize], CurrentTime) != GrabSuccess) {
                return;
+       }
+
        XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
+
        do {
                XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
                switch(ev.type) {
@@ -1568,10 +1903,10 @@ resizemouse(const Arg *arg) {
                        nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
                        nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
                        if(c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
-                       && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
+                          && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
                        {
                                if(!c->isfloating && selmon->lt[selmon->sellt]->arrange
-                               && (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
+                                  && (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
                                        togglefloating(NULL);
                        }
                        if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
@@ -1579,18 +1914,23 @@ resizemouse(const Arg *arg) {
                        break;
                }
        } while(ev.type != ButtonRelease);
+
        XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
        XUngrabPointer(dpy, CurrentTime);
+
        while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+
        if((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
                sendmon(c, m);
                selmon = m;
                focus(NULL);
        }
+
+       return;
 }
 
-void
-resizerequest(XEvent *e) {
+void resizerequest(XEvent *e)
+{
        XResizeRequestEvent *ev = &e->xresizerequest;
        Client *i;
 
@@ -1599,72 +1939,100 @@ resizerequest(XEvent *e) {
                resizebarwin(selmon);
                updatesystray();
        }
+
+       return;
 }
 
-void
-restack(Monitor *m) {
+void restack(Monitor *m)
+{
        Client *c;
        XEvent ev;
        XWindowChanges wc;
 
        drawbar(m);
-       if(!m->sel)
+
+       if(!m->sel) {
                return;
-       if(m->sel->isfloating || !m->lt[m->sellt]->arrange)
+       }
+
+       if(m->sel->isfloating || !m->lt[m->sellt]->arrange) {
                XRaiseWindow(dpy, m->sel->win);
+       }
+
        if(m->lt[m->sellt]->arrange) {
                wc.stack_mode = Below;
                wc.sibling = m->barwin;
-               for(c = m->stack; c; c = c->snext)
+               for(c = m->stack; c; c = c->snext) {
                        if(!c->isfloating && ISVISIBLE(c)) {
                                XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
                                wc.sibling = c->win;
                        }
+               }
        }
+
        XSync(dpy, False);
        while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+
+       return;
 }
 
-void
-run(void) {
+void run(void)
+{
        XEvent ev;
-       /* main event loop */
+
        XSync(dpy, False);
-       while(running && !XNextEvent(dpy, &ev))
-               if(handler[ev.type])
-                       handler[ev.type](&ev); /* call handler */
+       while(running && !XNextEvent(dpy, &ev)) {
+               if(handler[ev.type]) {
+                       handler[ev.type](&ev);
+               }
+       }
+
+       return;
 }
 
-void
-scan(void) {
+void scan(void)
+{
        unsigned int i, num;
        Window d1, d2, *wins = NULL;
        XWindowAttributes wa;
 
        if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
                for(i = 0; i < num; i++) {
-                       if(!XGetWindowAttributes(dpy, wins[i], &wa)
-                       || wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
+                       if(!XGetWindowAttributes(dpy, wins[i], &wa) ||
+                          wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) {
                                continue;
-                       if(wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
+                       }
+
+                       if(wa.map_state == IsViewable || getstate(wins[i]) == IconicState) {
                                manage(wins[i], &wa);
+                       }
                }
+
                for(i = 0; i < num; i++) { /* now the transients */
-                       if(!XGetWindowAttributes(dpy, wins[i], &wa))
+                       if(!XGetWindowAttributes(dpy, wins[i], &wa)) {
                                continue;
-                       if(XGetTransientForHint(dpy, wins[i], &d1)
-                       && (wa.map_state == IsViewable || getstate(wins[i]) == IconicState))
+                       }
+
+                       if(XGetTransientForHint(dpy, wins[i], &d1) &&
+                          (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)) {
                                manage(wins[i], &wa);
+                       }
                }
-               if(wins)
+
+               if(wins) {
                        XFree(wins);
+               }
        }
+
+       return;
 }
 
-void
-sendmon(Client *c, Monitor *m) {
-       if(c->mon == m)
+void sendmon(Client *c, Monitor *m)
+{
+       if(c->mon == m) {
                return;
+       }
+
        unfocus(c, True);
        detach(c);
        detachstack(c);
@@ -1674,18 +2042,22 @@ sendmon(Client *c, Monitor *m) {
        attachstack(c);
        focus(NULL);
        arrange(NULL);
+
+       return;
 }
 
-void
-setclientstate(Client *c, long state) {
+void setclientstate(Client *c, long state)
+{
        long data[] = { state, None };
 
        XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
                        PropModeReplace, (unsigned char *)data, 2);
+
+       return;
 }
 
-Bool
-sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d3, long d4) {
+Bool sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d3, long d4)
+{
        int n;
        Atom *protocols, mt;
        Bool exists = False;
@@ -1693,16 +2065,19 @@ sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d3, lo
 
        if(proto == wmatom[WMTakeFocus] || proto == wmatom[WMDelete]) {
                mt = wmatom[WMProtocols];
+
                if(XGetWMProtocols(dpy, w, &protocols, &n)) {
-                       while(!exists && n--)
+                       while(!exists && n--) {
                                exists = protocols[n] == proto;
+                       }
+
                        XFree(protocols);
                }
-       }
-       else {
+       } else {
                exists = True;
                mt = proto;
        }
+
        if(exists) {
                ev.type = ClientMessage;
                ev.xclient.window = w;
@@ -1715,19 +2090,24 @@ sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d3, lo
                ev.xclient.data.l[4] = d4;
                XSendEvent(dpy, w, False, mask, &ev);
        }
-       return exists;
+
+       return(exists);
 }
 
-void
-setfocus(Client *c) {
-       if(!c->neverfocus)
+void setfocus(Client *c)
+{
+       if(!c->neverfocus) {
                XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+       }
+
        XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
        sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
+
+       return;
 }
 
-void
-setfullscreen(Client *c, Bool fullscreen) {
+void setfullscreen(Client *c, Bool fullscreen)
+{
        if(fullscreen) {
                XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
                                PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
@@ -1738,8 +2118,7 @@ setfullscreen(Client *c, Bool fullscreen) {
                c->isfloating = True;
                resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
                XRaiseWindow(dpy, c->win);
-       }
-       else {
+       } else {
                XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
                                PropModeReplace, (unsigned char*)0, 0);
                c->isfullscreen = False;
@@ -1752,39 +2131,56 @@ setfullscreen(Client *c, Bool fullscreen) {
                resizeclient(c, c->x, c->y, c->w, c->h);
                arrange(c->mon);
        }
+
+       return;
 }
 
-void
-setlayout(const Arg *arg) {
-       if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+void setlayout(const Arg *arg)
+{
+       if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) {
                selmon->sellt ^= 1;
-       if(arg && arg->v)
+       }
+
+       if(arg && arg->v) {
                selmon->lt[selmon->sellt] = (Layout *)arg->v;
+       }
+
        strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
-       if(selmon->sel)
+
+       if(selmon->sel) {
                arrange(selmon);
-       else
+       } else {
                drawbar(selmon);
+       }
+
+       return;
 }
 
 #ifndef M10K
 /* arg > 1.0 will set mfact absolutly */
-void
-setmfact(const Arg *arg) {
+void setmfact(const Arg *arg)
+{
        float f;
 
-       if(!arg || !selmon->lt[selmon->sellt]->arrange)
+       if(!arg || !selmon->lt[selmon->sellt]->arrange) {
                return;
+       }
+
        f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
-       if(f < 0.1 || f > 0.9)
+
+       if(f < 0.1 || f > 0.9) {
                return;
+       }
+
        selmon->mfact = f;
        arrange(selmon);
+
+       return;
 }
 #endif /* ! M10K */
 
-void
-setup(void) {
+void setup(void)
+{
        XSetWindowAttributes wa;
 
        /* clean up any zombies immediately */
@@ -1841,101 +2237,151 @@ setup(void) {
        /* select for events */
        wa.cursor = cursor[CurNormal];
        wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask
-                       |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
+               |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
        XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
        XSelectInput(dpy, root, wa.event_mask);
        grabkeys();
+
+       return;
 }
 
-void
-showhide(Client *c) {
-       if(!c)
+void showhide(Client *c)
+{
+       if(!c) {
                return;
+       }
+
        if(ISVISIBLE(c)) { /* show clients top down */
                XMoveWindow(dpy, c->win, c->x, c->y);
-               if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
+
+               if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) {
                        resize(c, c->x, c->y, c->w, c->h, False);
+               }
+
                showhide(c->snext);
-       }
-       else { /* hide clients bottom up */
+       } else { /* hide clients bottom up */
                showhide(c->snext);
                XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
        }
+
+       return;
 }
 
-void
-sigchld(int unused) {
-       if(signal(SIGCHLD, sigchld) == SIG_ERR)
+void sigchld(int unused)
+{
+       if(signal(SIGCHLD, sigchld) == SIG_ERR) {
                die("Can't install SIGCHLD handler");
-       while(0 < waitpid(-1, NULL, WNOHANG));
+       }
+
+       while(waitpid(-1, NULL, WNOHANG) > 0);
+
+       return;
 }
 
-void
-spawn(const Arg *arg) {
+void spawn(const Arg *arg)
+{
        if(fork() == 0) {
-               if(dpy)
+               if(dpy) {
                        close(ConnectionNumber(dpy));
+               }
+
                setsid();
                execvp(((char **)arg->v)[0], (char **)arg->v);
                fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
                perror(" failed");
+
                exit(EXIT_SUCCESS);
        }
+
+       return;
 }
 
-void
-tag(const Arg *arg) {
+void tag(const Arg *arg)
+{
        if(selmon->sel && arg->ui & TAGMASK) {
                selmon->sel->tags = arg->ui & TAGMASK;
                focus(NULL);
                arrange(selmon);
        }
+
+       return;
 }
 
-void
-tagmon(const Arg *arg) {
-       if(!selmon->sel || !mons->next)
-               return;
-       sendmon(selmon->sel, dirtomon(arg->i));
+void tagmon(const Arg *arg)
+{
+       if(selmon->sel && mons->next) {
+               sendmon(selmon->sel, dirtomon(arg->i));
+       }
+
+       return;
 }
 
-int
-textnw(const char *text, unsigned int len) {
+int textnw(const char *text, unsigned int len)
+{
        PangoRectangle r;
-       if(text == stext && statusmarkup)
+
+       if(text == stext && statusmarkup) {
                pango_layout_set_markup(dc.font.layout, text, len);
-       else
+       } else {
                pango_layout_set_text(dc.font.layout, text, len);
+       }
+
        pango_layout_get_extents(dc.font.layout, 0, &r);
-       if(text == stext && statusmarkup) /* clear markup attributes */
+
+       if(text == stext && statusmarkup) {
+               /* clear markup attributes */
                pango_layout_set_attributes(dc.font.layout, NULL);
-       return r.width / PANGO_SCALE;
+       }
+
+       return(r.width / PANGO_SCALE);
 }
 
-void
-tile(Monitor *m) {
+void tile(Monitor *m)
+{
        unsigned int i, n, h, mw, my, ty;
        Client *c;
 
        for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
-       if(n == 0)
+
+       if(n == 0) {
                return;
+       }
 
-       if(n > m->nmaster)
+       if(n > m->nmaster) {
                mw = m->nmaster ? m->ww * m->mfact : 0;
-       else
+       } else {
                mw = m->ww;
-       for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+       }
+
+       for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
                if(i < m->nmaster) {
                        h = (m->wh - my) / (MIN(n, m->nmaster) - i);
                        resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
                        my += HEIGHT(c);
-               }
-               else {
+               } else {
                        h = (m->wh - ty) / (n - i);
                        resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
                        ty += HEIGHT(c);
                }
+       }
+
+       return;
+}
+
+static int count_tiled_clients(Monitor *mon)
+{
+       Client *tiled;
+       int n;
+
+       tiled = nexttiled(mon->clients);
+       n = 0;
+
+       while(tiled) {
+               tiled = nexttiled(tiled->next);
+               n++;
+       }
+
+       return(n);
 }
 
 static void bookshelf(Monitor *m)
@@ -1945,9 +2391,7 @@ static void bookshelf(Monitor *m)
 
         Client *c;
 
-       /* count the clients on this monitor */
-        for(n = 0, c = nexttiled(m->clients); c;
-           c = nexttiled(c->next), n++);
+       n = count_tiled_clients(m);
 
         if(!n) {
                /* nothing to do */
@@ -1997,9 +2441,7 @@ static void bookstack(Monitor *m)
         * The logic is essentially the same as in bookshelf(), though
         * much more vertical, literally speaking.
         */
-
-        for(n = 0, c = nexttiled(m->clients); c;
-           c = nexttiled(c->next), n++);
+       n = count_tiled_clients(m);
 
         if(!n) {
                 return;
@@ -2022,53 +2464,73 @@ static void bookstack(Monitor *m)
 }
 
 #ifndef M10K
-void
-togglebar(const Arg *arg) {
+void togglebar(const Arg *arg)
+{
        selmon->showbar = !selmon->showbar;
        updatebarpos(selmon);
        resizebarwin(selmon);
+
        if(showsystray) {
                XWindowChanges wc;
-               if(!selmon->showbar)
+
+               if(!selmon->showbar) {
                        wc.y = -bh;
-               else if(selmon->showbar) {
+               else if(selmon->showbar) {
                        wc.y = 0;
-                       if(!selmon->topbar)
+
+                       if(!selmon->topbar) {
                                wc.y = selmon->mh - bh;
+                       }
                }
+
                XConfigureWindow(dpy, systray->win, CWY, &wc);
        }
+
        arrange(selmon);
+
+       return;
 }
 #endif /* ! M10K */
 
-void
-togglefloating(const Arg *arg) {
-       if(!selmon->sel)
+void togglefloating(const Arg *arg)
+{
+       if(!selmon->sel) {
                return;
+       }
+
        selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
-       if(selmon->sel->isfloating)
+
+       if(selmon->sel->isfloating) {
                resize(selmon->sel, selmon->sel->x, selmon->sel->y,
                       selmon->sel->w, selmon->sel->h, False);
+       }
+
        arrange(selmon);
+
+       return;
 }
 
-void
-toggletag(const Arg *arg) {
+void toggletag(const Arg *arg)
+{
        unsigned int newtags;
 
-       if(!selmon->sel)
+       if(!selmon->sel) {
                return;
+       }
+
        newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
+
        if(newtags) {
                selmon->sel->tags = newtags;
                focus(NULL);
                arrange(selmon);
        }
+
+       return;
 }
 
-void
-toggleview(const Arg *arg) {
+void toggleview(const Arg *arg)
+{
        unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
 
        if(newtagset) {
@@ -2076,26 +2538,35 @@ toggleview(const Arg *arg) {
                focus(NULL);
                arrange(selmon);
        }
+
+       return;
 }
 
-void
-unfocus(Client *c, Bool setfocus) {
-       if(!c)
+void unfocus(Client *c, Bool setfocus)
+{
+       if(!c) {
                return;
+       }
+
        grabbuttons(c, False);
        XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
-       if(setfocus)
+
+       if(setfocus) {
                XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+       }
+
+       return;
 }
 
-void
-unmanage(Client *c, Bool destroyed) {
+void unmanage(Client *c, Bool destroyed)
+{
        Monitor *m = c->mon;
        XWindowChanges wc;
 
        /* The server grab construct avoids race conditions. */
        detach(c);
        detachstack(c);
+
        if(!destroyed) {
                wc.border_width = c->oldbw;
                XGrabServer(dpy);
@@ -2107,31 +2578,36 @@ unmanage(Client *c, Bool destroyed) {
                XSetErrorHandler(xerror);
                XUngrabServer(dpy);
        }
+
        free(c);
        focus(NULL);
        arrange(m);
+
+       return;
 }
 
-void
-unmapnotify(XEvent *e) {
+void unmapnotify(XEvent *e)
+{
        Client *c;
        XUnmapEvent *ev = &e->xunmap;
 
        if((c = wintoclient(ev->window))) {
-               if(ev->send_event)
+               if(ev->send_event) {
                        setclientstate(c, WithdrawnState);
-               else
+               } else {
                        unmanage(c, False);
-       }
-       else if((c = wintosystrayicon(ev->window))) {
+               }
+       else if((c = wintosystrayicon(ev->window))) {
                removesystrayicon(c);
                resizebarwin(selmon);
                updatesystray();
        }
+
+       return;
 }
 
-void
-updatebars(void) {
+void updatebars(void)
+{
        unsigned int w;
        Monitor *m;
 
@@ -2140,33 +2616,43 @@ updatebars(void) {
                .background_pixmap = ParentRelative,
                .event_mask = ButtonPressMask|ExposureMask
        };
+
        for(m = mons; m; m = m->next) {
                w = m->ww;
-               if(showsystray && m == selmon)
+
+               if(showsystray && m == selmon) {
                        w -= getsystraywidth();
+               }
+
                m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen),
                                          CopyFromParent, DefaultVisual(dpy, screen),
                                          CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+
                XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
                XMapRaised(dpy, m->barwin);
        }
+
+       return;
 }
 
-void
-updatebarpos(Monitor *m) {
+void updatebarpos(Monitor *m)
+{
        m->wy = m->my;
        m->wh = m->mh;
+
        if(m->showbar) {
                m->wh -= bh;
                m->by = m->topbar ? m->wy : m->wy + m->wh;
                m->wy = m->topbar ? m->wy + bh : m->wy;
-       }
-       else
+       } else {
                m->by = -bh;
+       }
+
+       return;
 }
 
-Bool
-updategeom(void) {
+Bool updategeom(void)
+{
        Bool dirty = False;
 
 #ifdef XINERAMA
@@ -2178,27 +2664,35 @@ updategeom(void) {
                XineramaScreenInfo *unique = NULL;
 
                for(n = 0, m = mons; m; m = m->next, n++);
+
                /* only consider unique geometries as separate screens */
-               if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn)))
+               if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn))) {
                        die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn);
-               for(i = 0, j = 0; i < nn; i++)
-                       if(isuniquegeom(unique, j, &info[i]))
+               }
+
+               for(i = 0, j = 0; i < nn; i++) {
+                       if(isuniquegeom(unique, j, &info[i])) {
                                memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
+                       }
+               }
+
                XFree(info);
                nn = j;
+
                if(n <= nn) {
                        for(i = 0; i < (nn - n); i++) { /* new monitors available */
                                for(m = mons; m && m->next; m = m->next);
-                               if(m)
+
+                               if(m) {
                                        m->next = createmon();
-                               else
+                               } else {
                                        mons = createmon();
+                               }
                        }
-                       for(i = 0, m = mons; i < nn && m; m = m->next, i++)
-                               if(i >= n
-                               || (unique[i].x_org != m->mx || unique[i].y_org != m->my
-                                   || unique[i].width != m->mw || unique[i].height != m->mh))
-                               {
+
+                       for(i = 0, m = mons; i < nn && m; m = m->next, i++) {
+                               if(i >= n || (unique[i].x_org != m->mx || unique[i].y_org != m->my ||
+                                   unique[i].width != m->mw || unique[i].height != m->mh)) {
                                        dirty = True;
                                        m->num = i;
                                        m->mx = m->wx = unique[i].x_org;
@@ -2207,10 +2701,11 @@ updategeom(void) {
                                        m->mh = m->wh = unique[i].height;
                                        updatebarpos(m);
                                }
-               }
-               else { /* less monitors available nn < n */
+                       }
+               else { /* less monitors available nn < n */
                        for(i = nn; i < n; i++) {
                                for(m = mons; m && m->next; m = m->next);
+
                                while(m->clients) {
                                        dirty = True;
                                        c = m->clients;
@@ -2220,19 +2715,24 @@ updategeom(void) {
                                        attach(c);
                                        attachstack(c);
                                }
-                               if(m == selmon)
+
+                               if(m == selmon) {
                                        selmon = mons;
+                               }
+
                                cleanupmon(m);
                        }
                }
+
                free(unique);
-       }
-       else
+       } else
 #endif /* XINERAMA */
-       /* default monitor setup */
+               /* default monitor setup */
        {
-               if(!mons)
+               if(!mons) {
                        mons = createmon();
+               }
+
                if(mons->mw != sw || mons->mh != sh) {
                        dirty = True;
                        mons->mw = mons->ww = sw;
@@ -2240,155 +2740,192 @@ updategeom(void) {
                        updatebarpos(mons);
                }
        }
+
        if(dirty) {
                selmon = mons;
                selmon = wintomon(root);
        }
-       return dirty;
+
+       return(dirty);
 }
 
-void
-updatenumlockmask(void) {
+void updatenumlockmask(void)
+{
        unsigned int i, j;
        XModifierKeymap *modmap;
 
        numlockmask = 0;
        modmap = XGetModifierMapping(dpy);
-       for(i = 0; i < 8; i++)
-               for(j = 0; j < modmap->max_keypermod; j++)
-                       if(modmap->modifiermap[i * modmap->max_keypermod + j]
-                          == XKeysymToKeycode(dpy, XK_Num_Lock))
+
+       for(i = 0; i < 8; i++) {
+               for(j = 0; j < modmap->max_keypermod; j++) {
+                       if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock)) {
                                numlockmask = (1 << i);
+                       }
+               }
+       }
+
        XFreeModifiermap(modmap);
+
+       return;
 }
 
-void
-updatesizehints(Client *c) {
+void updatesizehints(Client *c)
+{
        long msize;
        XSizeHints size;
 
-       if(!XGetWMNormalHints(dpy, c->win, &size, &msize))
+       if(!XGetWMNormalHints(dpy, c->win, &size, &msize)) {
                /* size is uninitialized, ensure that size.flags aren't used */
                size.flags = PSize;
+       }
+
        if(size.flags & PBaseSize) {
                c->basew = size.base_width;
                c->baseh = size.base_height;
-       }
-       else if(size.flags & PMinSize) {
+       } else if(size.flags & PMinSize) {
                c->basew = size.min_width;
                c->baseh = size.min_height;
-       }
-       else
+       } else {
                c->basew = c->baseh = 0;
+       }
+
        if(size.flags & PResizeInc) {
                c->incw = size.width_inc;
                c->inch = size.height_inc;
-       }
-       else
+       } else {
                c->incw = c->inch = 0;
+       }
+
        if(size.flags & PMaxSize) {
                c->maxw = size.max_width;
                c->maxh = size.max_height;
-       }
-       else
+       } else {
                c->maxw = c->maxh = 0;
+       }
+
        if(size.flags & PMinSize) {
                c->minw = size.min_width;
                c->minh = size.min_height;
-       }
-       else if(size.flags & PBaseSize) {
+       } else if(size.flags & PBaseSize) {
                c->minw = size.base_width;
                c->minh = size.base_height;
-       }
-       else
+       } else {
                c->minw = c->minh = 0;
+       }
+
        if(size.flags & PAspect) {
                c->mina = (float)size.min_aspect.y / size.min_aspect.x;
                c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
-       }
-       else
+       } else {
                c->maxa = c->mina = 0.0;
+       }
+
        c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
-                    && c->maxw == c->minw && c->maxh == c->minh);
+                     && c->maxw == c->minw && c->maxh == c->minh);
+
+       return;
 }
 
-void
-updatetitle(Client *c) {
-       if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
+void updatetitle(Client *c)
+{
+       if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) {
                gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
-       if(c->name[0] == '\0') /* hack to mark broken clients */
+       }
+
+       if(c->name[0] == '\0') {
+               /* hack to mark broken clients */
                strcpy(c->name, broken);
+       }
+
+       return;
 }
 
-void
-updatestatus(void) {
-       if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
+void updatestatus(void)
+{
+       if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
                strcpy(stext, "dwm-"VERSION);
+       }
+
        drawbar(selmon);
+       return;
 }
 
-void
-updatesystrayicongeom(Client *i, int w, int h) {
+void updatesystrayicongeom(Client *i, int w, int h)
+{
        if(i) {
                i->h = bh;
-               if(w == h)
+               if(w == h) {
                        i->w = bh;
-               else if(h == bh)
+               } else if(h == bh) {
                        i->w = w;
-               else
+               } else {
                        i->w = (int) ((float)bh * ((float)w / (float)h));
+               }
+
                applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False);
                /* force icons into the systray dimenons if they don't want to */
                if(i->h > bh) {
-                       if(i->w == i->h)
+                       if(i->w == i->h) {
                                i->w = bh;
-                       else
+                       } else {
                                i->w = (int) ((float)bh * ((float)i->w / (float)i->h));
+                       }
+
                        i->h = bh;
                }
        }
+
+       return;
 }
 
-void
-updatesystrayiconstate(Client *i, XPropertyEvent *ev) {
+void updatesystrayiconstate(Client *i, XPropertyEvent *ev)
+{
        long flags;
        int code = 0;
 
        if(!showsystray || !i || ev->atom != xatom[XembedInfo] ||
-                       !(flags = getatomprop(i, xatom[XembedInfo])))
+          !(flags = getatomprop(i, xatom[XembedInfo]))) {
                return;
+       }
 
        if(flags & XEMBED_MAPPED && !i->tags) {
                i->tags = 1;
                code = XEMBED_WINDOW_ACTIVATE;
                XMapRaised(dpy, i->win);
                setclientstate(i, NormalState);
-       }
-       else if(!(flags & XEMBED_MAPPED) && i->tags) {
+       } else if(!(flags & XEMBED_MAPPED) && i->tags) {
                i->tags = 0;
                code = XEMBED_WINDOW_DEACTIVATE;
                XUnmapWindow(dpy, i->win);
                setclientstate(i, WithdrawnState);
-       }
-       else
+       } else {
                return;
+       }
+
        sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime, code, 0,
-                       systray->win, XEMBED_EMBEDDED_VERSION);
+                 systray->win, XEMBED_EMBEDDED_VERSION);
+
+       return;
 }
 
-void
-updatesystray(void) {
+void updatesystray(void)
+{
        XSetWindowAttributes wa;
        Client *i;
        unsigned int x = selmon->mx + selmon->mw;
        unsigned int w = 1;
 
-       if(!showsystray)
+       if(!showsystray) {
                return;
+       }
+
        if(!systray) {
                /* init systray */
-               if(!(systray = (Systray *)calloc(1, sizeof(Systray))))
+               if(!(systray = (Systray *)calloc(1, sizeof(Systray)))) {
                        die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
+               }
+
                systray->win = XCreateSimpleWindow(dpy, root, x, selmon->by, w, bh, 0, 0, dc.sel[ColBG]);
                wa.event_mask        = ButtonPressMask | ExposureMask;
                wa.override_redirect = True;
@@ -2400,25 +2937,30 @@ updatesystray(void) {
                XChangeWindowAttributes(dpy, systray->win, CWEventMask|CWOverrideRedirect|CWBackPixel|CWBackPixmap, &wa);
                XMapRaised(dpy, systray->win);
                XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime);
+
                if(XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) {
                        sendevent(root, xatom[Manager], StructureNotifyMask, CurrentTime, netatom[NetSystemTray], systray->win, 0, 0);
                        XSync(dpy, False);
-               }
-               else {
+               } else {
                        fprintf(stderr, "dwm: unable to obtain system tray.\n");
                        free(systray);
                        systray = NULL;
+
                        return;
                }
        }
+
        for(w = 0, i = systray->icons; i; i = i->next) {
                XMapRaised(dpy, i->win);
                w += systrayspacing;
                XMoveResizeWindow(dpy, i->win, (i->x = w), 0, i->w, i->h);
                w += i->w;
-               if(i->mon != selmon)
+
+               if(i->mon != selmon) {
                        i->mon = selmon;
+               }
        }
+
        w = w ? w + systrayspacing : 1;
        x -= w;
        XMoveResizeWindow(dpy, systray->win, x, selmon->by, w, bh);
@@ -2426,149 +2968,202 @@ updatesystray(void) {
        XSetForeground(dpy, dc.gc, dc.norm[ColBG]);
        XFillRectangle(dpy, systray->win, dc.gc, 0, 0, w, bh);
        XSync(dpy, False);
+
+       return;
 }
 
-void
-updatewindowtype(Client *c) {
+void updatewindowtype(Client *c)
+{
        Atom state = getatomprop(c, netatom[NetWMState]);
        Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
 
-       if(state == netatom[NetWMFullscreen])
+       if(state == netatom[NetWMFullscreen]) {
                setfullscreen(c, True);
+       }
 
-       if(wtype == netatom[NetWMWindowTypeDialog])
+       if(wtype == netatom[NetWMWindowTypeDialog]) {
                c->isfloating = True;
+       }
+
+       return;
 }
 
-void
-updatewmhints(Client *c) {
+void updatewmhints(Client *c)
+{
        XWMHints *wmh;
 
        if((wmh = XGetWMHints(dpy, c->win))) {
                if(c == selmon->sel && wmh->flags & XUrgencyHint) {
                        wmh->flags &= ~XUrgencyHint;
                        XSetWMHints(dpy, c->win, wmh);
-               }
-               else
+               } else {
                        c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
-               if(wmh->flags & InputHint)
+               }
+
+               if(wmh->flags & InputHint) {
                        c->neverfocus = !wmh->input;
-               else
+               } else {
                        c->neverfocus = False;
+               }
+
                XFree(wmh);
        }
+
+       return;
 }
 
-void
-view(const Arg *arg) {
-       if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+void view(const Arg *arg)
+{
+       if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) {
                return;
+       }
+
        selmon->seltags ^= 1; /* toggle sel tagset */
-       if(arg->ui & TAGMASK)
+
+       if(arg->ui & TAGMASK) {
                selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+       }
+
        arrange(selmon);
        focus(NULL);
+
+       return;
 }
 
-Client *
-wintoclient(Window w) {
+Client *wintoclient(Window w)
+{
        Client *c;
        Monitor *m;
 
-       for(m = mons; m; m = m->next)
-               for(c = m->clients; c; c = c->next)
-                       if(c->win == w)
-                               return c;
-       return NULL;
+       for(m = mons; m; m = m->next) {
+               for(c = m->clients; c; c = c->next) {
+                       if(c->win == w) {
+                               return(c);
+                       }
+               }
+       }
+
+       return(NULL);
 }
 
-Monitor *
-wintomon(Window w) {
+Monitor *wintomon(Window w)
+{
        int x, y;
        Client *c;
        Monitor *m;
 
-       if(w == root && getrootptr(&x, &y))
-               return recttomon(x, y, 1, 1);
-       for(m = mons; m; m = m->next)
-               if(w == m->barwin)
-                       return m;
-       if((c = wintoclient(w)))
-               return c->mon;
-       return selmon;
+       if(w == root && getrootptr(&x, &y)) {
+               return(recttomon(x, y, 1, 1));
+       }
+
+       for(m = mons; m; m = m->next) {
+               if(w == m->barwin) {
+                       return(m);
+               }
+       }
+
+       if((c = wintoclient(w))) {
+               return(c->mon);
+       }
+
+       return(selmon);
 }
 
-Client *
-wintosystrayicon(Window w) {
+Client *wintosystrayicon(Window w)
+{
        Client *i = NULL;
 
-       if(!showsystray || !w)
-               return i;
-       for(i = systray->icons; i && i->win != w; i = i->next) ;
-       return i;
+       if(!showsystray || !w) {
+               return(i);
+       }
+
+       for(i = systray->icons; i && i->win != w; i = i->next);
+
+       return(i);
 }
 
 /* There's no way to check accesses to destroyed windows, thus those cases are
  * ignored (especially on UnmapNotify's).  Other types of errors call Xlibs
  * default error handler, which may call exit.  */
-int
-xerror(Display *dpy, XErrorEvent *ee) {
-       if(ee->error_code == BadWindow
-       || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
-       || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
-       || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
-       || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
-       || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
-       || (ee->request_code == X_GrabButton && ee->error_code == BadAccess)
-       || (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
-       || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
+int xerror(Display *dpy, XErrorEvent *ee)
+{
+       if(ee->error_code == BadWindow ||
+          (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) ||
+          (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) ||
+          (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) ||
+          (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) ||
+          (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) ||
+          (ee->request_code == X_GrabButton && ee->error_code == BadAccess) ||
+          (ee->request_code == X_GrabKey && ee->error_code == BadAccess) ||
+          (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) {
                return 0;
+       }
+
        fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
-                       ee->request_code, ee->error_code);
-       return xerrorxlib(dpy, ee); /* may call exit */
+               ee->request_code, ee->error_code);
+
+       return(xerrorxlib(dpy, ee)); /* may call exit */
 }
 
-int
-xerrordummy(Display *dpy, XErrorEvent *ee) {
-       return 0;
+int xerrordummy(Display *dpy, XErrorEvent *ee)
+{
+       return(0);
 }
 
 /* Startup Error handler to check if another window manager
  * is already running. */
-int
-xerrorstart(Display *dpy, XErrorEvent *ee) {
+int xerrorstart(Display *dpy, XErrorEvent *ee)
+{
        die("dwm: another window manager is already running\n");
-       return -1;
+       return(-1);
 }
 
-void
-zoom(const Arg *arg) {
+void zoom(const Arg *arg)
+{
        Client *c = selmon->sel;
 
-       if(!selmon->lt[selmon->sellt]->arrange
-       || (selmon->sel && selmon->sel->isfloating))
+       if(!selmon->lt[selmon->sellt]->arrange ||
+          (selmon->sel && selmon->sel->isfloating)) {
                return;
-       if(c == nexttiled(selmon->clients))
-               if(!c || !(c = nexttiled(c->next)))
+       }
+
+       if(c == nexttiled(selmon->clients)) {
+               if(!c || !(c = nexttiled(c->next))){
                        return;
+               }
+       }
+
        pop(c);
+       return;
 }
 
-int
-main(int argc, char *argv[]) {
-       if(argc == 2 && !strcmp("-v", argv[1]))
+int main(int argc, char *argv[])
+{
+       if(argc == 2 && !strcmp("-v", argv[1])) {
                die("dwm-"VERSION", © 2006-2011 dwm engineers, see LICENSE for details\n");
-       else if(argc != 1)
+       } else if(argc != 1) {
                die("usage: dwm [-v]\n");
-       if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+       }
+
+       if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) {
                fputs("warning: no locale support\n", stderr);
-       if(!(dpy = XOpenDisplay(NULL)))
+       }
+
+       dpy = XOpenDisplay(NULL);
+
+       if(!dpy) {
                die("dwm: cannot open display\n");
-       checkotherwm();
+       }
+
+       if(checkotherwm() < 0) {
+               die("dwm: Detected another window manager\n");
+       }
+
        setup();
        scan();
        run();
        cleanup();
        XCloseDisplay(dpy);
+
        return EXIT_SUCCESS;
 }