]> git.corax.cc Git - dwm/commitdiff
Split long lines
authorMatthias Kruk <m@m10k.eu>
Sat, 13 Mar 2021 05:35:23 +0000 (14:35 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 13 Mar 2021 05:35:23 +0000 (14:35 +0900)
There are several lines in the source code that do not fit on a reasonably
sized screen. This commit breaks up all long lines so they fit within 95
columns.

dwm.c

diff --git a/dwm.c b/dwm.c
index 7e30b3da97d2ef95357f9a2f56da2ff56f6b6b8d..f3abd9eb532261bf1c960930e13a4d95de090ba6 100755 (executable)
--- a/dwm.c
+++ b/dwm.c
 #include <X11/extensions/Xinerama.h>
 #endif /* XINERAMA */
 
-#define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
-#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
+#define BUTTONMASK              (ButtonPressMask | ButtonReleaseMask)
+#define ALLMODMASK              (Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
+#define ALLMASK                 (ShiftMask | ControlMask | ALLMODMASK)
+#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask) & ALLMASK)
 #define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
 #define LENGTH(X)               (sizeof X / sizeof X[0])
 #ifndef MAX
@@ -248,7 +250,8 @@ struct systray {
 
 /* function declarations */
 static void applyrules(struct client *c);
-static Bool applysizehints(struct client *c, int *x, int *y, int *w, int *h, Bool interact);
+static Bool applysizehints(struct client *c, int *x, int *y,
+                          int *w, int *h, Bool interact);
 static void arrange(struct monitor *m);
 static void arrangemon(struct monitor *m);
 static void attach(struct client *c);
@@ -270,8 +273,10 @@ static void die(const char *errstr, ...);
 static struct monitor *dirtomon(int dir);
 static void drawbar(struct monitor *m);
 static void drawbars(void);
-static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
-static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
+static void drawsquare(Bool filled, Bool empty, Bool invert,
+                      unsigned long col[ColLast]);
+static void drawtext(const char *text, unsigned long col[ColLast],
+                    Bool invert);
 #ifndef M10K
 static void enternotify(XEvent *e);
 #endif /* ! M10K */
@@ -312,7 +317,8 @@ static void resizerequest(XEvent *e);
 static void restack(struct monitor *m);
 static void run(void);
 static void scan(void);
-static Bool sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
+static Bool sendevent(Window w, Atom proto, int m, long d0,
+                     long d1, long d2, long d3, long d4);
 static void sendmon(struct client *c, struct monitor *m);
 static void setclientstate(struct client *c, long state);
 static void setfocus(struct client *c);
@@ -587,7 +593,7 @@ void arrange(struct monitor *m)
 
 void arrangemon(struct monitor *m)
 {
-       strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
+       strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof(m->ltsymbol));
 
        if(m->lt[m->sellt]->arrange) {
                m->lt[m->sellt]->arrange(m);
@@ -654,9 +660,11 @@ void buttonpress(XEvent *e)
        }
 
        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)) {
-                       buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
+               if(click == buttons[i].click && buttons[i].func &&
+                  buttons[i].button == ev->button &&
+                  CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) {
+                       buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ?
+                                       &arg : &buttons[i].arg);
                }
        }
 
@@ -682,28 +690,43 @@ int checkotherwm(void)
 
 void cleanup(void)
 {
-       union arg a = {.ui = ~0};
-        struct layout foo = { "", NULL };
+        struct layout foo;
         struct monitor *m;
+       union arg a;
        int i;
 
+       a.ui = ~0;
+       foo.symbol = "";
+       foo.arrange = NULL;
+
        view(&a);
        selmon->lt[selmon->sellt] = &foo;
-       for(m = mons; m; m = m->next)
-               while(m->stack)
+
+       for(m = mons; m; m = m->next) {
+               while(m->stack) {
                        unmanage(m->stack, False);
+               }
+       }
+
        XUngrabKey(dpy, AnyKey, AnyModifier, root);
        XFreePixmap(dpy, dc.drawable);
+
        for(i = ColBorder; i < ColLast; i++) {
-               XftColorFree(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), dc.xft.norm + i);
-               XftColorFree(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), dc.xft.sel + i);
+               XftColorFree(dpy, DefaultVisual(dpy, screen),
+                            DefaultColormap(dpy, screen),
+                            dc.xft.norm + i);
+               XftColorFree(dpy, DefaultVisual(dpy, screen),
+                            DefaultColormap(dpy, screen),
+                            dc.xft.sel + i);
        }
+
        XftDrawDestroy(dc.xft.drawable);
        g_object_unref(dc.font.layout);
        XFreeGC(dpy, dc.gc);
        XFreeCursor(dpy, cursor[CurNormal]);
        XFreeCursor(dpy, cursor[CurResize]);
        XFreeCursor(dpy, cursor[CurMove]);
+
        while(mons) {
                cleanupmon(mons);
        }
@@ -714,21 +737,26 @@ void cleanup(void)
 
        XSync(dpy, False);
        XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
+
+       return;
 }
 
 void cleanupmon(struct monitor *mon)
 {
         struct monitor *m;
 
-       if(mon == mons)
+       if(mon == mons) {
                mons = mons->next;
-       else {
+       else {
                for(m = mons; m && m->next != mon; m = m->next);
                m->next = mon->next;
        }
+
        XUnmapWindow(dpy, mon->barwin);
        XDestroyWindow(dpy, mon->barwin);
        free(mon);
+
+       return;
 }
 
 void clearurgent(struct client *c)
@@ -741,6 +769,8 @@ void clearurgent(struct client *c)
        wmh->flags &= ~XUrgencyHint;
        XSetWMHints(dpy, c->win, wmh);
        XFree(wmh);
+
+       return;
 }
 
 void clientmessage(XEvent *e)
@@ -750,11 +780,16 @@ void clientmessage(XEvent *e)
        XClientMessageEvent *cme = &e->xclient;
         struct client *c = wintoclient(cme->window);
 
-       if(cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) {
+       if(cme->window == systray->win &&
+          cme->message_type == netatom[NetSystemTrayOP]) {
                /* add systray icons */
                if(cme->data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) {
-                       if(!(c = (struct client*)calloc(1, sizeof(*c))))
+                       c = (struct client*)calloc(1, sizeof(*c));
+
+                       if(!c) {
                                die("fatal: could not malloc() %u bytes\n", sizeof(*c));
+                       }
+
                        c->win = cme->data.l[2];
                        c->mon = selmon;
                        c->next = systray->icons;
@@ -773,24 +808,36 @@ void clientmessage(XEvent *e)
                        c->isfloating = True;
                        /* reuse tags field as mapped status */
                        c->tags = 1;
+
                        updatesizehints(c);
                        updatesystrayicongeom(c, wa.width, wa.height);
                        XAddToSaveSet(dpy, c->win);
-                       XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
+                       XSelectInput(dpy, c->win, StructureNotifyMask |
+                                    PropertyChangeMask | ResizeRedirectMask);
                        XReparentWindow(dpy, c->win, systray->win, 0, 0);
+
                        /* use parents background pixmap */
                        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);
+                       XChangeWindowAttributes(dpy, c->win,
+                                               CWBackPixmap | CWBackPixel,
+                                               &swa);
+
+                       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);
@@ -804,9 +851,15 @@ void clientmessage(XEvent *e)
        }
 
        if(cme->message_type == netatom[NetWMState]) {
-               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)));
+               if(cme->data.l[1] == netatom[NetWMFullscreen] ||
+                  cme->data.l[2] == netatom[NetWMFullscreen]) {
+                       int fs;
+
+                       fs = cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ ||
+                               (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ &&
+                                !c->isfullscreen);
+
+                       setfullscreen(c, fs);
                }
        } else if(cme->message_type == netatom[NetActiveWindow]) {
                if(!ISVISIBLE(c)) {
@@ -855,8 +908,8 @@ void configurenotify(XEvent *e)
                                XFreePixmap(dpy, dc.drawable);
                        }
 
-                       dc.drawable = XCreatePixmap(dpy, root, screen_width,
-                                                   bar_height, DefaultDepth(dpy, screen));
+                       dc.drawable = XCreatePixmap(dpy, root, screen_width, bar_height,
+                                                   DefaultDepth(dpy, screen));
                        XftDrawChange(dc.xft.drawable, dc.drawable);
                        updatebars();
 
@@ -876,9 +929,11 @@ void configurerequest(XEvent *e)
 {
         struct client *c;
         struct monitor *m;
-       XConfigureRequestEvent *ev = &e->xconfigurerequest;
+       XConfigureRequestEvent *ev;
        XWindowChanges wc;
 
+       ev = &e->xconfigurerequest;
+
        if((c = wintoclient(ev->window))) {
                if(ev->value_mask & CWBorderWidth) {
                        c->border.w = ev->border_width;
@@ -902,18 +957,27 @@ void configurerequest(XEvent *e)
                                c->geom.h = ev->height;
                        }
 
-                       if((c->geom.x + c->geom.w) > m->geom.x + m->geom.w && c->isfloating) {
-                               c->geom.x = m->geom.x + (m->geom.w / 2 - client_get_width(c) / 2); /* center in x direction */
-                       }
-                       if((c->geom.y + c->geom.h) > m->geom.y + m->geom.h && c->isfloating) {
-                               c->geom.y = m->geom.y + (m->geom.h / 2 - client_get_height(c) / 2); /* center in y direction */
+                       if(c->isfloating) {
+                               if((c->geom.x + c->geom.w) > m->geom.x + m->geom.w) {
+                                       /* center in x direction */
+                                       c->geom.x = m->geom.x +
+                                               (m->geom.w / 2 - client_get_width(c) / 2);
+                               }
+                               if((c->geom.y + c->geom.h) > m->geom.y + m->geom.h) {
+                                       /* center in y direction */
+                                       c->geom.y = m->geom.y +
+                                               (m->geom.h / 2 - client_get_height(c) / 2);
+                               }
                        }
-                       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)) {
-                               XMoveResizeWindow(dpy, c->win, c->geom.x, c->geom.y, c->geom.w, c->geom.h);
+                               XMoveResizeWindow(dpy, c->win, c->geom.x, c->geom.y,
+                                                 c->geom.w, c->geom.h);
                        }
                } else {
                        configure(c);
@@ -938,16 +1002,20 @@ struct monitor *createmon(void)
 {
         struct monitor *m;
 
-       if(!(m = (struct monitor *)calloc(1, sizeof(*m)))) {
+       m = (struct monitor *)calloc(1, sizeof(*m));
+
+       if(!m) {
                die("fatal: could not malloc() %u bytes\n", sizeof(*m));
        }
 
-       m->tagset[0] = m->tagset[1] = 1;
+       m->tagset[0] = 1;
+       m->tagset[1] = 1;
        m->mfact = mfact;
        m->nmaster = nmaster;
        m->topbar = topbar;
        m->lt[0] = &layouts[0];
        m->lt[1] = &layouts[1 % LENGTH(layouts)];
+
        strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
 
        return(m);
@@ -1078,7 +1146,8 @@ void drawbar(struct monitor *m)
                }
        }
 
-       XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->win_geom.w, bar_height, 0, 0);
+       XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0,
+                 m->win_geom.w, bar_height, 0, 0);
        XSync(dpy, False);
 
        return;
@@ -1104,9 +1173,13 @@ void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]
        XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
        x = (dc.font.ascent + dc.font.descent + 2) / 4;
        if(filled) {
-               XFillRectangle(dpy, dc.drawable, dc.gc, dc.geom.x + 1, dc.geom.y + 1, x + 1, x + 1);
+               XFillRectangle(dpy, dc.drawable, dc.gc,
+                              dc.geom.x + 1, dc.geom.y + 1,
+                              x + 1, x + 1);
        } else if(empty) {
-               XDrawRectangle(dpy, dc.drawable, dc.gc, dc.geom.x + 1, dc.geom.y + 1, x, x);
+               XDrawRectangle(dpy, dc.drawable, dc.gc,
+                              dc.geom.x + 1, dc.geom.y + 1,
+                              x, x);
        }
 
        return;
@@ -1118,7 +1191,9 @@ void drawtext(const char *text, unsigned long col[ColLast], Bool invert)
        int i, x, y, h, len, olen;
 
        XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
-       XFillRectangle(dpy, dc.drawable, dc.gc, dc.geom.x, dc.geom.y, dc.geom.w, dc.geom.h);
+       XFillRectangle(dpy, dc.drawable, dc.gc,
+                      dc.geom.x, dc.geom.y,
+                      dc.geom.w, dc.geom.h);
 
        if(!text) {
                return;
@@ -1133,7 +1208,7 @@ void drawtext(const char *text, unsigned long col[ColLast], Bool invert)
           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.geom.w - h; len--);
 
-       if(!len) {
+       if(len <= 0) {
                return;
        }
 
@@ -1150,7 +1225,8 @@ void drawtext(const char *text, unsigned long col[ColLast], Bool invert)
        }
 
        pango_xft_render_layout(dc.xft.drawable,
-                               (col == dc.norm ? dc.xft.norm : dc.xft.sel) + (invert ? ColBG : ColFG),
+                               (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 */
@@ -1167,7 +1243,8 @@ void enternotify(XEvent *e)
         struct 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;
        }
 
@@ -1359,8 +1436,10 @@ long getstate(Window w)
        unsigned long n, extra;
        Atom real;
 
-       if(XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
-                             &real, &format, &n, &extra, (unsigned char **)&p) != Success) {
+       if(XGetWindowProperty(dpy, w, wmatom[WMState], 0L,
+                             2L, False, wmatom[WMState],
+                             &real, &format, &n, &extra,
+                             (unsigned char **)&p) != Success) {
                return -1;
        }
 
@@ -1409,7 +1488,8 @@ Bool gettextprop(Window w, Atom atom, char *text, unsigned int size)
        if(name.encoding == XA_STRING) {
                strncpy(text, (char *)name.value, size - 1);
        } else {
-               if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
+               if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success &&
+                  n > 0 && *list) {
                        strncpy(text, *list, size - 1);
                        XFreeStringList(list);
                }
@@ -1426,8 +1506,11 @@ void grabbuttons(struct client *c, Bool focused)
        updatenumlockmask();
        {
                unsigned int i, j;
-               unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
+               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) {
@@ -1435,7 +1518,8 @@ void grabbuttons(struct client *c, Bool focused)
                                                XGrabButton(dpy, buttons[i].button,
                                                            buttons[i].mask | modifiers[j],
                                                            c->win, False, BUTTONMASK,
-                                                           GrabModeAsync, GrabModeSync, None, None);
+                                                           GrabModeAsync, GrabModeSync,
+                                                           None, None);
                                        }
                                }
                        }
@@ -1453,10 +1537,12 @@ void grabkeys(void)
        updatenumlockmask();
        {
                unsigned int i, j;
-               unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
+               unsigned int modifiers[] = { 0, LockMask, numlockmask,
+                                            numlockmask | LockMask };
                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++) {
@@ -1601,7 +1687,8 @@ void manage(Window w, XWindowAttributes *wa)
        /* only fix client y-offset, if the client center might cover the bar */
        c->geom.y = MAX(c->geom.y, (c->mon->by == c->mon->geom.y &&
                                    (c->geom.x + (c->geom.w / 2) >= c->mon->win_geom.x) &&
-                                   (c->geom.x + (c->geom.w / 2) < c->mon->win_geom.x + c->mon->win_geom.w)) ? bar_height : c->mon->geom.y);
+                                   (c->geom.x + (c->geom.w / 2) < c->mon->win_geom.x +
+                                    c->mon->win_geom.w)) ? bar_height : c->mon->geom.y);
        c->border.w = borderpx;
 
        wc.border_width = c->border.w;
@@ -1611,7 +1698,8 @@ void manage(Window w, XWindowAttributes *wa)
        updatewindowtype(c);
        updatesizehints(c);
        updatewmhints(c);
-       XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
+       XSelectInput(dpy, w, EnterWindowMask | FocusChangeMask |
+                    PropertyChangeMask | StructureNotifyMask);
        grabbuttons(c, False);
 
        if(!c->isfloating) {
@@ -1624,7 +1712,10 @@ void manage(Window w, XWindowAttributes *wa)
 
        attach(c);
        attachstack(c);
-       XMoveResizeWindow(dpy, c->win, c->geom.x + 2 * screen_width, c->geom.y, c->geom.w, c->geom.h); /* some windows require this */
+
+       /* some windows require this */
+       XMoveResizeWindow(dpy, c->win, c->geom.x + 2 * screen_width,
+                         c->geom.y, c->geom.w, c->geom.h);
        setclientstate(c, NormalState);
 
        if (c->mon == selmon) {
@@ -1762,18 +1853,23 @@ void movemouse(const union arg *arg)
                           ny <= selmon->win_geom.y + selmon->win_geom.h) {
                                if(abs(selmon->win_geom.x - nx) < snap) {
                                        nx = selmon->win_geom.x;
-                               } else if(abs((selmon->win_geom.x + selmon->win_geom.w) - (nx + client_get_width(c))) < snap) {
-                                       nx = selmon->win_geom.x + selmon->win_geom.w - client_get_width(c);
+                               } else if(abs((selmon->win_geom.x + selmon->win_geom.w) -
+                                             (nx + client_get_width(c))) < snap) {
+                                       nx = selmon->win_geom.x + selmon->win_geom.w -
+                                               client_get_width(c);
                                }
 
                                if(abs(selmon->win_geom.y - ny) < snap) {
                                        ny = selmon->win_geom.y;
-                               } else if(abs((selmon->win_geom.y + selmon->win_geom.h) - (ny + client_get_height(c))) < snap) {
-                                       ny = selmon->win_geom.y + selmon->win_geom.h - client_get_height(c);
+                               } else if(abs((selmon->win_geom.y + selmon->win_geom.h) -
+                                             (ny + client_get_height(c))) < snap) {
+                                       ny = selmon->win_geom.y + selmon->win_geom.h -
+                                               client_get_height(c);
                                }
 
                                if(!c->isfloating && selmon->lt[selmon->sellt]->arrange &&
-                                  (abs(nx - c->geom.x) > snap || abs(ny - c->geom.y) > snap)) {
+                                  (abs(nx - c->geom.x) > snap ||
+                                   abs(ny - c->geom.y) > snap)) {
                                        togglefloating(NULL);
                                }
                        }
@@ -1996,7 +2092,9 @@ void resizemouse(const union arg *arg)
                return;
        }
 
-       XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geom.w + c->border.w - 1, c->geom.h + c->border.w - 1);
+       XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
+                    c->geom.w + c->border.w - 1,
+                    c->geom.h + c->border.w - 1);
 
        do {
                XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
@@ -2011,21 +2109,28 @@ void resizemouse(const union arg *arg)
                        nw = MAX(ev.xmotion.x - ocx - 2 * c->border.w + 1, 1);
                        nh = MAX(ev.xmotion.y - ocy - 2 * c->border.w + 1, 1);
                        if(c->mon->win_geom.x + nw >= selmon->win_geom.x &&
-                          c->mon->win_geom.x + nw <= selmon->win_geom.x + selmon->win_geom.w &&
+                          c->mon->win_geom.x + nw <= (selmon->win_geom.x +
+                                                      selmon->win_geom.w) &&
                           c->mon->win_geom.y + nh >= selmon->win_geom.y &&
-                          c->mon->win_geom.y + nh <= selmon->win_geom.y + selmon->win_geom.h)
-                       {
+                          c->mon->win_geom.y + nh <= (selmon->win_geom.y +
+                                                      selmon->win_geom.h)) {
                                if(!c->isfloating && selmon->lt[selmon->sellt]->arrange
-                                  && (abs(nw - c->geom.w) > snap || abs(nh - c->geom.h) > snap))
+                                  && (abs(nw - c->geom.w) > snap ||
+                                      abs(nh - c->geom.h) > snap)) {
                                        togglefloating(NULL);
+                               }
                        }
-                       if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+                       if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) {
                                resize(c, c->geom.x, c->geom.y, nw, nh, True);
+                       }
+
                        break;
                }
        } while(ev.type != ButtonRelease);
 
-       XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geom.w + c->border.w - 1, c->geom.h + c->border.w - 1);
+       XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
+                    c->geom.w + c->border.w - 1,
+                    c->geom.h + c->border.w - 1);
        XUngrabPointer(dpy, CurrentTime);
 
        while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@@ -2216,7 +2321,8 @@ void setfocus(struct client *c)
        }
 
        XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geom.w / 2, c->geom.h / 2);
-       sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
+       sendevent(c->win, wmatom[WMTakeFocus], NoEventMask,
+                 wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
 
        return;
 }
@@ -2224,14 +2330,16 @@ void setfocus(struct client *c)
 void setfullscreen(struct client *c, Bool fullscreen)
 {
        if(fullscreen) {
-               XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
-                               PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
+               XChangeProperty(dpy, c->win, netatom[NetWMState],
+                               XA_ATOM, 32, PropModeReplace,
+                               (unsigned char*)&netatom[NetWMFullscreen], 1);
                c->isfullscreen = True;
                c->oldstate = c->isfloating;
                c->border.oldw = c->border.w;
                c->border.w = 0;
                c->isfloating = True;
-               resizeclient(c, c->mon->geom.x, c->mon->geom.y, c->mon->geom.w, c->mon->geom.h);
+               resizeclient(c, c->mon->geom.x, c->mon->geom.y,
+                            c->mon->geom.w, c->mon->geom.h);
                XRaiseWindow(dpy, c->win);
        } else {
                XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
@@ -2257,7 +2365,8 @@ void setlayout(const union arg *arg)
                selmon->lt[selmon->sellt] = (struct layout*)arg->v;
        }
 
-       strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
+       strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol,
+               sizeof(selmon->ltsymbol));
 
        if(selmon->sel) {
                arrange(selmon);
@@ -2315,12 +2424,16 @@ void setup(void)
        netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
        netatom[NetSystemTray] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_S0", False);
        netatom[NetSystemTrayOP] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False);
-       netatom[NetSystemTrayOrientation] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION", False);
+       netatom[NetSystemTrayOrientation] = XInternAtom(dpy,
+                                                       "_NET_SYSTEM_TRAY_ORIENTATION",
+                                                       False);
        netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
        netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
        netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
        netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
-       netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
+       netatom[NetWMWindowTypeDialog] = XInternAtom(dpy,
+                                                    "_NET_WM_WINDOW_TYPE_DIALOG",
+                                                    False);
        xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
        xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False);
        xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
@@ -2335,8 +2448,10 @@ void setup(void)
        dc.sel[ColBorder] = getcolor(selbordercolor, dc.xft.sel + ColBorder);
        dc.sel[ColBG] = getcolor(selbgcolor, dc.xft.sel + ColBG);
        dc.sel[ColFG] = getcolor(selfgcolor, dc.xft.sel + ColFG);
-       dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bar_height, DefaultDepth(dpy, screen));
-       dc.xft.drawable = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen));
+       dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen),
+                                   bar_height, DefaultDepth(dpy, screen));
+       dc.xft.drawable = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen),
+                                       DefaultColormap(dpy, screen));
        dc.gc = XCreateGC(dpy, root, 0, NULL);
        XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
        updatesystray();
@@ -2348,8 +2463,9 @@ void setup(void)
                        PropModeReplace, (unsigned char *) netatom, NetLast);
        /* select for events */
        wa.cursor = cursor[CurNormal];
-       wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask
-               |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
+       wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | ButtonPressMask |
+               PointerMotionMask | EnterWindowMask | LeaveWindowMask | StructureNotifyMask |
+               PropertyChangeMask;
        XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
        XSelectInput(dpy, root, wa.event_mask);
        grabkeys();
@@ -2366,7 +2482,8 @@ void showhide(struct client *c)
        if(ISVISIBLE(c)) { /* show clients top down */
                XMoveWindow(dpy, c->win, c->geom.x, c->geom.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->geom.x, c->geom.y, c->geom.w, c->geom.h, False);
                }
 
@@ -2540,7 +2657,8 @@ static void bookshelf(struct monitor *m)
                c->incw = 0;
                c->inch = 0;
 
-                resize(c, x, m->win_geom.y, w + extraw - border, m->win_geom.h - border, False);
+                resize(c, x, m->win_geom.y, w + extraw - border,
+                      m->win_geom.h - border, False);
 
                /*
                 * Since all clients are horizontally aligned and the
@@ -2581,7 +2699,8 @@ static void bookstack(struct monitor *m)
                c->incw = 0;
                c->inch = 0;
 
-                resize(c, m->win_geom.x, y, m->win_geom.w - border, h + extrah - border, False);
+                resize(c, m->win_geom.x, y, m->win_geom.w - border,
+                      h + extrah - border, False);
                 y += client_get_height(c);
                extrah = 0;
         }
@@ -2717,7 +2836,8 @@ void updatebars(void)
        for(m = mons; m; m = m->next) {
                w = m->win_geom.w - getsystraywidth();
 
-               m->barwin = XCreateWindow(dpy, root, m->win_geom.x, m->by, w, bar_height, 0, DefaultDepth(dpy, screen),
+               m->barwin = XCreateWindow(dpy, root, m->win_geom.x, m->by,
+                                         w, bar_height, 0, DefaultDepth(dpy, screen),
                                          CopyFromParent, DefaultVisual(dpy, screen),
                                          CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
 
@@ -2779,8 +2899,10 @@ Bool updategeom(void)
                        }
 
                        for(i = 0, m = mons; i < nn && m; m = m->next, i++) {
-                               if(i >= n || (unique[i].x_org != m->geom.x || unique[i].y_org != m->geom.y ||
-                                   unique[i].width != m->geom.w || unique[i].height != m->geom.h)) {
+                               if(i >= n || (unique[i].x_org != m->geom.x ||
+                                             unique[i].y_org != m->geom.y ||
+                                             unique[i].width != m->geom.w ||
+                                             unique[i].height != m->geom.h)) {
                                        dirty = True;
                                        m->num = i;
                                        m->geom.x = unique[i].x_org;
@@ -2788,7 +2910,8 @@ Bool updategeom(void)
                                        m->geom.w = unique[i].width;
                                        m->geom.h = unique[i].height;
 
-                                       memcpy(&(m->win_geom), &(m->geom), sizeof(m->win_geom));
+                                       memcpy(&(m->win_geom), &(m->geom),
+                                              sizeof(m->win_geom));
 
                                        updatebarpos(m);
                                }
@@ -2850,7 +2973,8 @@ void updatenumlockmask(void)
 
        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)) {
+                       if(modmap->modifiermap[i * modmap->max_keypermod + j] ==
+                          XKeysymToKeycode(dpy, XK_Num_Lock)) {
                                numlockmask = (1 << i);
                        }
                }
@@ -2964,7 +3088,8 @@ void updatesystrayicongeom(struct client *i, int w, int h)
                if(i->geom.w == i->geom.h) {
                        i->geom.w = bar_height;
                } else {
-                       i->geom.w = (int) ((float)bar_height * ((float)i->geom.w / (float)i->geom.h));
+                       i->geom.w = (int) ((float)bar_height * ((float)i->geom.w /
+                                                               (float)i->geom.h));
                }
 
                i->geom.h = bar_height;
@@ -3019,20 +3144,26 @@ void updatesystray(void)
                        die("fatal: could not malloc() %u bytes\n", sizeof(*systray));
                }
 
-               systray->win = XCreateSimpleWindow(dpy, root, x, selmon->by, w, bar_height, 0, 0, dc.sel[ColBG]);
+               systray->win = XCreateSimpleWindow(dpy, root, x, selmon->by,
+                                                  w, bar_height, 0, 0, dc.sel[ColBG]);
                wa.event_mask        = ButtonPressMask | ExposureMask;
                wa.override_redirect = True;
                wa.background_pixmap = ParentRelative;
                wa.background_pixel  = dc.norm[ColBG];
                XSelectInput(dpy, systray->win, SubstructureNotifyMask);
-               XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32,
-                               PropModeReplace, (unsigned char *)&systrayorientation, 1);
-               XChangeWindowAttributes(dpy, systray->win, CWEventMask|CWOverrideRedirect|CWBackPixel|CWBackPixmap, &wa);
+               XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation],
+                               XA_CARDINAL, 32, PropModeReplace,
+                               (unsigned char *)&systrayorientation, 1);
+               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);
+                       sendevent(root, xatom[Manager], StructureNotifyMask,
+                                 CurrentTime, netatom[NetSystemTray],
+                                 systray->win, 0, 0);
                        XSync(dpy, False);
                } else {
                        fprintf(stderr, "dwm: unable to obtain system tray.\n");
@@ -3047,7 +3178,8 @@ void updatesystray(void)
                XMapRaised(dpy, i->win);
                w += systrayspacing;
                i->geom.x = w;
-               XMoveResizeWindow(dpy, i->win, i->geom.x, 0, i->geom.w, i->geom.h);
+               XMoveResizeWindow(dpy, i->win, i->geom.x, 0,
+                                 i->geom.w, i->geom.h);
                w += i->geom.w;
 
                if(i->mon != selmon) {