]> git.corax.cc Git - dwm/commitdiff
Don't hide structs and unions behind typedefs
authorMatthias Kruk <matthias.kruk@miraclelinux.com>
Sat, 13 Mar 2021 00:17:11 +0000 (09:17 +0900)
committerMatthias Kruk <matthias.kruk@miraclelinux.com>
Sat, 13 Mar 2021 00:17:11 +0000 (09:17 +0900)
To make it more obvious, what kind of data one is dealing with, remove
typedefs that are hiding structs and unions.

config.def.h
dwm.c

index 2e77d59ad920e026d22595b5ff80e0675c524a4c..840f77d51aa7d283fba35ec4dff836f604706898 100755 (executable)
@@ -19,7 +19,7 @@ static const Bool statusmarkup      = True;     /* True means use pango markup i
 /* tagging */
 static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
 
-static const Rule rules[] = {
+static const struct rule rules[] = {
        /* class      instance    title       tags mask     isfloating   monitor */
        { "Gimp",     NULL,       NULL,       0,            True,        -1 },
        { "Firefox",  NULL,       NULL,       0,            False,       -1 },
@@ -36,7 +36,7 @@ static const Bool resizehints = True; /* True means respect size hints in tiled
 #define LAYOUT_FLOAT     3
 #define LAYOUT_MONOCLE   4
 
-static const Layout layouts[] = {
+static const struct layout layouts[] = {
        /* symbol     arrange function */
        { "|||",      bookshelf }, /* first entry is default */
        { "===",      bookstack },
@@ -60,7 +60,7 @@ static const Layout layouts[] = {
 static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
 static const char *termcmd[]  = { "uxterm", NULL };
 
-static Key keys[] = {
+static struct key keys[] = {
        /* modifier                     key             function        argument */
 
        /* get the zap keyboard shortcut back */
@@ -124,7 +124,7 @@ static Key keys[] = {
 
 /* button definitions */
 /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
-static Button buttons[] = {
+static struct button buttons[] = {
        /* click                event mask      button          function        argument */
        { ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
        { ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[LAYOUT_MONOCLE]} },
diff --git a/dwm.c b/dwm.c
index d9794f1f10a78597ae0b681386803957f3393029..3a43fb8f23c1051cc027c7f4e02a8d39c73dec72 100755 (executable)
--- a/dwm.c
+++ b/dwm.c
@@ -133,40 +133,51 @@ enum {
        ClkLast
 };
 
-typedef union {
+union arg {
        int i;
        unsigned int ui;
        float f;
        const void *v;
-} Arg;
+};
 
-typedef struct {
+struct button {
        unsigned int click;
        unsigned int mask;
        unsigned int button;
-       void (*func)(const Arg *arg);
-       const Arg arg;
-} Button;
-
-typedef struct Monitor Monitor;
-typedef struct Client Client;
+       void (*func)(const union arg *arg);
+       const union arg arg;
+};
 
-struct Client {
+struct client {
        char name[256];
-       float mina, maxa;
-       int x, y, w, h;
-       int oldx, oldy, oldw, oldh;
-       int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+       float mina;
+       float maxa;
+       int x;
+       int y;
+       int w;
+       int h;
+       int oldx;
+       int oldy;
+       int oldw;
+       int oldh;
+       int basew;
+       int baseh;
+       int incw;
+       int inch;
+       int maxw;
+       int maxh;
+       int minw;
+       int minh;
        int bw, oldbw;
        unsigned int tags;
        Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
-       Client *next;
-       Client *snext;
-       Monitor *mon;
+       struct client *next;
+       struct client *snext;
+       struct monitor *mon;
        Window win;
 };
 
-typedef struct {
+struct draw_context {
        int x;
        int y;
        int w;
@@ -189,21 +200,21 @@ typedef struct {
                int height;
                PangoLayout *layout;
        } font;
-} DC; /* draw context */
+};
 
-typedef struct {
+struct key {
        unsigned int mod;
        KeySym keysym;
-       void (*func)(const Arg *);
-       const Arg arg;
-} Key;
+       void (*func)(const union arg *);
+       const union arg arg;
+};
 
-typedef struct {
+struct layout {
        const char *symbol;
-       void (*arrange)(Monitor *);
-} Layout;
+       void (*arrange)(struct monitor *);
+};
 
-struct Monitor {
+struct monitor {
        char ltsymbol[16];
        float mfact;
        int nmaster;
@@ -222,52 +233,51 @@ struct Monitor {
        unsigned int tagset[2];
        Bool showbar;
        Bool topbar;
-       Client *clients;
-       Client *sel;
-       Client *stack;
-       Monitor *next;
+       struct client *clients;
+       struct client *sel;
+       struct client *stack;
+       struct monitor *next;
        Window barwin;
-       const Layout *lt[2];
+       const struct layout *lt[2];
 };
 
-typedef struct {
+struct rule {
        const char *class;
        const char *instance;
        const char *title;
        unsigned int tags;
        Bool isfloating;
        int monitor;
-} Rule;
+};
 
-typedef struct Systray   Systray;
-struct Systray {
+struct systray {
        Window win;
-       Client *icons;
+       struct client *icons;
 };
 
 /* function declarations */
-static void applyrules(Client *c);
-static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
-static void arrange(Monitor *m);
-static void arrangemon(Monitor *m);
-static void attach(Client *c);
-static void attachstack(Client *c);
+static void applyrules(struct client *c);
+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);
+static void attachstack(struct client *c);
 static void buttonpress(XEvent *e);
 static int checkotherwm(void);
 static void cleanup(void);
-static void cleanupmon(Monitor *mon);
-static void clearurgent(Client *c);
+static void cleanupmon(struct monitor *mon);
+static void clearurgent(struct client *c);
 static void clientmessage(XEvent *e);
-static void configure(Client *c);
+static void configure(struct client *c);
 static void configurenotify(XEvent *e);
 static void configurerequest(XEvent *e);
-static Monitor *createmon(void);
+static struct monitor *createmon(void);
 static void destroynotify(XEvent *e);
-static void detach(Client *c);
-static void detachstack(Client *c);
+static void detach(struct client *c);
+static void detachstack(struct client *c);
 static void die(const char *errstr, ...);
-static Monitor *dirtomon(int dir);
-static void drawbar(Monitor *m);
+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);
@@ -275,95 +285,95 @@ static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
 static void enternotify(XEvent *e);
 #endif /* ! M10K */
 static void expose(XEvent *e);
-static void focus(Client *c);
+static void focus(struct client *c);
 static void focusin(XEvent *e);
-static void focusmon(const Arg *arg);
-static void focusstack(const Arg *arg);
+static void focusmon(const union arg *arg);
+static void focusstack(const union arg *arg);
 static unsigned long getcolor(const char *colstr, XftColor *color);
 static Bool getrootptr(int *x, int *y);
 static long getstate(Window w);
 static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
-static void grabbuttons(Client *c, Bool focused);
+static void grabbuttons(struct client *c, Bool focused);
 static void grabkeys(void);
-static void incnmaster(const Arg *arg);
+static void incnmaster(const union arg *arg);
 static void initfont(const char *fontstr);
 static void keypress(XEvent *e);
-static void killclient(const Arg *arg);
+static void killclient(const union arg *arg);
 static void manage(Window w, XWindowAttributes *wa);
 static void mappingnotify(XEvent *e);
 static void maprequest(XEvent *e);
-static void monocle(Monitor *m);
+static void monocle(struct monitor *m);
 #ifndef M10K
 static void motionnotify(XEvent *e);
 #endif /* ! M10K */
-static void movemouse(const Arg *arg);
-static Client *nexttiled(Client *c);
-static void pop(Client *);
+static void movemouse(const union arg *arg);
+static struct client *nexttiled(struct client *c);
+static void pop(struct client *);
 static void propertynotify(XEvent *e);
-static void quit(const Arg *arg);
-static Monitor *recttomon(int x, int y, int w, int h);
-static void removesystrayicon(Client *i);
-static void resize(Client *c, int x, int y, int w, int h, Bool interact);
-static void resizebarwin(Monitor *m);
-static void resizeclient(Client *c, int x, int y, int w, int h);
-static void resizemouse(const Arg *arg);
+static void quit(const union arg *arg);
+static struct monitor *recttomon(int x, int y, int w, int h);
+static void removesystrayicon(struct client *i);
+static void resize(struct client *c, int x, int y, int w, int h, Bool interact);
+static void resizebarwin(struct monitor *m);
+static void resizeclient(struct client *c, int x, int y, int w, int h);
+static void resizemouse(const union arg *arg);
 static void resizerequest(XEvent *e);
-static void restack(Monitor *m);
+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 void sendmon(Client *c, Monitor *m);
-static void setclientstate(Client *c, long state);
-static void setfocus(Client *c);
-static void setfullscreen(Client *c, Bool fullscreen);
-static void setlayout(const Arg *arg);
+static void sendmon(struct client *c, struct monitor *m);
+static void setclientstate(struct client *c, long state);
+static void setfocus(struct client *c);
+static void setfullscreen(struct client *c, Bool fullscreen);
+static void setlayout(const union arg *arg);
 #ifndef M10K
-static void setmfact(const Arg *arg);
+static void setmfact(const union arg *arg);
 #endif /* ! M10K */
 static void setup(void);
-static void showhide(Client *c);
+static void showhide(struct client *c);
 static void sigchld(int unused);
-static void spawn(const Arg *arg);
-static void tag(const Arg *arg);
-static void tagmon(const Arg *arg);
+static void spawn(const union arg *arg);
+static void tag(const union arg *arg);
+static void tagmon(const union arg *arg);
 static int textnw(const char *text, unsigned int len);
-static void tile(Monitor *);
+static void tile(struct monitor *monitor);
 #ifndef M10K
-static void togglebar(const Arg *arg);
+static void togglebar(const union arg *arg);
 #endif /* ! M10K */
-static void togglefloating(const Arg *arg);
-static void toggletag(const Arg *arg);
-static void toggleview(const Arg *arg);
-static void unfocus(Client *c, Bool setfocus);
-static void unmanage(Client *c, Bool destroyed);
+static void togglefloating(const union arg *arg);
+static void toggletag(const union arg *arg);
+static void toggleview(const union arg *arg);
+static void unfocus(struct client *c, Bool setfocus);
+static void unmanage(struct client *c, Bool destroyed);
 static void unmapnotify(XEvent *e);
 static Bool updategeom(void);
-static void updatebarpos(Monitor *m);
+static void updatebarpos(struct monitor *m);
 static void updatebars(void);
 static void updatenumlockmask(void);
-static void updatesizehints(Client *c);
+static void updatesizehints(struct client *c);
 static void updatestatus(void);
 static void updatesystray(void);
-static void updatesystrayicongeom(Client *i, int w, int h);
-static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
-static void updatewindowtype(Client *c);
-static void updatetitle(Client *c);
-static void updatewmhints(Client *c);
-static void view(const Arg *arg);
-static Client *wintoclient(Window w);
-static Monitor *wintomon(Window w);
-static Client *wintosystrayicon(Window w);
+static void updatesystrayicongeom(struct client *i, int w, int h);
+static void updatesystrayiconstate(struct client *i, XPropertyEvent *ev);
+static void updatewindowtype(struct client *c);
+static void updatetitle(struct client *c);
+static void updatewmhints(struct client *c);
+static void view(const union arg *arg);
+static struct client *wintoclient(Window w);
+static struct monitor *wintomon(Window w);
+static struct client *wintosystrayicon(Window w);
 static int xerror(Display *dpy, XErrorEvent *ee);
 static int xerrordummy(Display *dpy, XErrorEvent *ee);
 static int xerrorstart(Display *dpy, XErrorEvent *ee);
-static void zoom(const Arg *arg);
-static Atom getatomprop(Client *c, Atom prop);
+static void zoom(const union arg *arg);
+static Atom getatomprop(struct client *c, Atom prop);
 static unsigned int getsystraywidth(void);
-static void bookshelf(Monitor*);
-static void bookstack(Monitor*);
+static void bookshelf(struct monitor *mon);
+static void bookstack(struct monitor *mon);
 
 /* variables */
-static Systray *systray = NULL;
+static struct systray *systray = NULL;
 static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
 static const char broken[] = "broken";
 static char stext[512];
@@ -401,23 +411,26 @@ static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];
 static Bool running = True;
 static Cursor cursor[CurLast];
 static Display *dpy;
-static DC dc;
-static Monitor *mons = NULL, *selmon = NULL;
+static struct draw_context dc;
+static struct monitor *mons = NULL;
+static struct monitor *selmon = NULL;
 static Window root;
 
 /* configuration, allows nested code to access above variables */
 #include "config.h"
 
 /* compile-time check if all tags fit into an unsigned int bit array. */
-struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+struct NumTags {
+       char limitexceeded[LENGTH(tags) > 31 ? -1 : 1];
+};
 
 /* function implementations */
-void applyrules(Client *c)
+void applyrules(struct client *c)
 {
        const char *class, *instance;
        unsigned int i;
-       const Rule *r;
-       Monitor *m;
+       const struct rule *r;
+        struct monitor *m;
        XClassHint ch = { NULL, NULL };
 
        /* rule matching */
@@ -456,10 +469,10 @@ void applyrules(Client *c)
        return;
 }
 
-Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact)
+Bool applysizehints(struct client *c, int *x, int *y, int *w, int *h, Bool interact)
 {
        Bool baseismin;
-       Monitor *m = c->mon;
+        struct monitor *m = c->mon;
 
        /* set minimum possible */
        *w = MAX(1, *w);
@@ -546,7 +559,7 @@ Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact)
        return(*x != c->x || *y != c->y || *w != c->w || *h != c->h);
 }
 
-void arrange(Monitor *m)
+void arrange(struct monitor *m)
 {
        if(m) {
                showhide(m->stack);
@@ -567,7 +580,7 @@ void arrange(Monitor *m)
        return;
 }
 
-void arrangemon(Monitor *m)
+void arrangemon(struct monitor *m)
 {
        strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
 
@@ -580,7 +593,7 @@ void arrangemon(Monitor *m)
        return;
 }
 
-void attach(Client *c)
+void attach(struct client *c)
 {
        c->next = c->mon->clients;
        c->mon->clients = c;
@@ -588,7 +601,7 @@ void attach(Client *c)
        return;
 }
 
-void attachstack(Client *c)
+void attachstack(struct client *c)
 {
        c->snext = c->mon->stack;
        c->mon->stack = c;
@@ -599,9 +612,9 @@ void attachstack(Client *c)
 void buttonpress(XEvent *e)
 {
        unsigned int i, x, click;
-       Arg arg = {0};
-       Client *c;
-       Monitor *m;
+       union arg arg = {0};
+        struct client *c;
+        struct monitor *m;
        XButtonPressedEvent *ev = &e->xbutton;
 
        click = ClkRootWin;
@@ -664,9 +677,9 @@ int checkotherwm(void)
 
 void cleanup(void)
 {
-       Arg a = {.ui = ~0};
-       Layout foo = { "", NULL };
-       Monitor *m;
+       union arg a = {.ui = ~0};
+        struct layout foo = { "", NULL };
+        struct monitor *m;
        int i;
 
        view(&a);
@@ -697,9 +710,9 @@ void cleanup(void)
        XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
 }
 
-void cleanupmon(Monitor *mon)
+void cleanupmon(struct monitor *mon)
 {
-       Monitor *m;
+        struct monitor *m;
 
        if(mon == mons)
                mons = mons->next;
@@ -712,7 +725,7 @@ void cleanupmon(Monitor *mon)
        free(mon);
 }
 
-void clearurgent(Client *c)
+void clearurgent(struct client *c)
 {
        XWMHints *wmh;
 
@@ -729,13 +742,13 @@ void clientmessage(XEvent *e)
        XWindowAttributes wa;
        XSetWindowAttributes swa;
        XClientMessageEvent *cme = &e->xclient;
-       Client *c = wintoclient(cme->window);
+        struct client *c = wintoclient(cme->window);
 
        if(showsystray && cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) {
                /* add systray icons */
                if(cme->data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) {
-                       if(!(c = (Client *)calloc(1, sizeof(Client))))
-                               die("fatal: could not malloc() %u bytes\n", sizeof(Client));
+                       if(!(c = (struct client*)calloc(1, sizeof(*c))))
+                               die("fatal: could not malloc() %u bytes\n", sizeof(*c));
                        c->win = cme->data.l[2];
                        c->mon = selmon;
                        c->next = systray->icons;
@@ -795,7 +808,7 @@ void clientmessage(XEvent *e)
        return;
 }
 
-void configure(Client *c)
+void configure(struct client *c)
 {
        XConfigureEvent ce;
 
@@ -817,7 +830,7 @@ void configure(Client *c)
 
 void configurenotify(XEvent *e)
 {
-       Monitor *m;
+        struct monitor *m;
        XConfigureEvent *ev = &e->xconfigure;
        Bool dirty;
 
@@ -849,8 +862,8 @@ void configurenotify(XEvent *e)
 
 void configurerequest(XEvent *e)
 {
-       Client *c;
-       Monitor *m;
+        struct client *c;
+        struct monitor *m;
        XConfigureRequestEvent *ev = &e->xconfigurerequest;
        XWindowChanges wc;
 
@@ -909,12 +922,12 @@ void configurerequest(XEvent *e)
        return;
 }
 
-Monitor *createmon(void)
+struct monitor *createmon(void)
 {
-       Monitor *m;
+        struct monitor *m;
 
-       if(!(m = (Monitor *)calloc(1, sizeof(Monitor)))) {
-               die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
+       if(!(m = (struct monitor *)calloc(1, sizeof(*m)))) {
+               die("fatal: could not malloc() %u bytes\n", sizeof(*m));
        }
 
        m->tagset[0] = m->tagset[1] = 1;
@@ -931,7 +944,7 @@ Monitor *createmon(void)
 
 void destroynotify(XEvent *e)
 {
-       Client *c;
+        struct client *c;
        XDestroyWindowEvent *ev = &e->xdestroywindow;
 
        if((c = wintoclient(ev->window))) {
@@ -945,9 +958,9 @@ void destroynotify(XEvent *e)
        return;
 }
 
-void detach(Client *c)
+void detach(struct client *c)
 {
-       Client **tc;
+        struct client **tc;
 
        for(tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
        *tc = c->next;
@@ -955,9 +968,9 @@ void detach(Client *c)
        return;
 }
 
-void detachstack(Client *c)
+void detachstack(struct client *c)
 {
-       Client **tc, *t;
+        struct client **tc, *t;
 
        for(tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext);
        *tc = c->snext;
@@ -982,9 +995,9 @@ void die(const char *errstr, ...)
        return;
 }
 
-Monitor *dirtomon(int dir)
+struct monitor *dirtomon(int dir)
 {
-       Monitor *m = NULL;
+       struct monitor *m = NULL;
 
        if(dir > 0) {
                if(!(m = selmon->next))
@@ -998,12 +1011,12 @@ Monitor *dirtomon(int dir)
        return(m);
 }
 
-void drawbar(Monitor *m)
+void drawbar(struct monitor *m)
 {
        int x;
        unsigned int i, occ = 0, urg = 0;
        unsigned long *col;
-       Client *c;
+        struct client *c;
 
        resizebarwin(m);
 
@@ -1065,7 +1078,7 @@ void drawbar(Monitor *m)
 
 void drawbars(void)
 {
-       Monitor *m;
+        struct monitor *m;
 
        for(m = mons; m; m = m->next) {
                drawbar(m);
@@ -1142,8 +1155,8 @@ void drawtext(const char *text, unsigned long col[ColLast], Bool invert)
 #ifndef M10K
 void enternotify(XEvent *e)
 {
-       Client *c;
-       Monitor *m;
+        struct client *c;
+        struct monitor *m;
        XCrossingEvent *ev = &e->xcrossing;
 
        if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) {
@@ -1168,7 +1181,7 @@ void enternotify(XEvent *e)
 
 void expose(XEvent *e)
 {
-       Monitor *m;
+        struct monitor *m;
        XExposeEvent *ev = &e->xexpose;
 
        if(ev->count == 0 && (m = wintomon(ev->window))) {
@@ -1178,7 +1191,7 @@ void expose(XEvent *e)
        return;
 }
 
-void focus(Client *c)
+void focus(struct client *c)
 {
        if(!c || !ISVISIBLE(c)) {
                for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
@@ -1225,9 +1238,9 @@ void focusin(XEvent *e)
        return;
 }
 
-void focusmon(const Arg *arg)
+void focusmon(const union arg *arg)
 {
-       Monitor *m;
+        struct monitor *m;
 
        if(!mons->next) {
                return;
@@ -1244,9 +1257,9 @@ void focusmon(const Arg *arg)
        return;
 }
 
-void focusstack(const Arg *arg)
+void focusstack(const union arg *arg)
 {
-       Client *c = NULL, *i;
+        struct client *c = NULL, *i;
 
        if(!selmon->sel) {
                return;
@@ -1281,7 +1294,7 @@ void focusstack(const Arg *arg)
        return;
 }
 
-Atom getatomprop(Client *c, Atom prop)
+Atom getatomprop(struct client *c, Atom prop)
 {
        int di;
        unsigned long dl;
@@ -1355,7 +1368,7 @@ long getstate(Window w)
 unsigned int getsystraywidth(void)
 {
        unsigned int w = 0;
-       Client *i;
+        struct client *i;
        if(showsystray) {
                for(i = systray->icons; i; w += i->w + systrayspacing, i = i->next) ;
        }
@@ -1389,7 +1402,7 @@ Bool gettextprop(Window w, Atom atom, char *text, unsigned int size)
        return(True);
 }
 
-void grabbuttons(Client *c, Bool focused)
+void grabbuttons(struct client *c, Bool focused)
 {
        updatenumlockmask();
        {
@@ -1438,7 +1451,7 @@ void grabkeys(void)
        return;
 }
 
-void incnmaster(const Arg *arg)
+void incnmaster(const union arg *arg)
 {
        selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
        arrange(selmon);
@@ -1503,7 +1516,7 @@ void keypress(XEvent *e)
        return;
 }
 
-void killclient(const Arg *arg)
+void killclient(const union arg *arg)
 {
        if(selmon->sel && !sendevent(selmon->sel->win, wmatom[WMDelete],
                                     NoEventMask, wmatom[WMDelete],
@@ -1522,12 +1535,16 @@ void killclient(const Arg *arg)
 
 void manage(Window w, XWindowAttributes *wa)
 {
-       Client *c, *t = NULL;
-       Window trans = None;
+        struct client *c;
+       struct client *t;
+       Window trans;
        XWindowChanges wc;
 
-       if(!(c = calloc(1, sizeof(Client)))) {
-               die("fatal: could not malloc() %u bytes\n", sizeof(Client));
+       t = NULL;
+       trans = None;
+
+       if(!(c = calloc(1, sizeof(*c)))) {
+               die("fatal: could not malloc() %u bytes\n", sizeof(*c));
        }
 
        c->win = w;
@@ -1603,7 +1620,7 @@ void maprequest(XEvent *e)
 {
        static XWindowAttributes wa;
        XMapRequestEvent *ev = &e->xmaprequest;
-       Client *i;
+        struct client *i;
 
        if((i = wintosystrayicon(ev->window))) {
                sendevent(i->win, netatom[Xembed], StructureNotifyMask,
@@ -1622,10 +1639,10 @@ void maprequest(XEvent *e)
        return;
 }
 
-void monocle(Monitor *m)
+void monocle(struct monitor *m)
 {
        unsigned int n = 0;
-       Client *c;
+        struct client *c;
 
        for(c = m->clients; c; c = c->next) {
                if(ISVISIBLE(c)) {
@@ -1647,8 +1664,8 @@ void monocle(Monitor *m)
 #ifndef M10K
 void motionnotify(XEvent *e)
 {
-       static Monitor *mon = NULL;
-       Monitor *m;
+       static struct monitor *mon = NULL;
+        struct monitor *m;
        XMotionEvent *ev = &e->xmotion;
 
        if(ev->window != root) {
@@ -1665,11 +1682,11 @@ void motionnotify(XEvent *e)
 }
 #endif /* ! M10K */
 
-void movemouse(const Arg *arg)
+void movemouse(const union arg *arg)
 {
        int x, y, ocx, ocy, nx, ny;
-       Client *c;
-       Monitor *m;
+        struct client *c;
+        struct monitor *m;
        XEvent ev;
 
        if(!(c = selmon->sel)) {
@@ -1724,14 +1741,14 @@ void movemouse(const Arg *arg)
        return;
 }
 
-Client *nexttiled(Client *c)
+struct client *nexttiled(struct client *c)
 {
        for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
 
        return(c);
 }
 
-void pop(Client *c)
+void pop(struct client *c)
 {
        detach(c);
        attach(c);
@@ -1743,7 +1760,7 @@ void pop(Client *c)
 
 void propertynotify(XEvent *e)
 {
-       Client *c;
+        struct client *c;
        Window trans;
        XPropertyEvent *ev = &e->xproperty;
 
@@ -1789,19 +1806,27 @@ void propertynotify(XEvent *e)
        return;
 }
 
-void quit(const Arg *arg)
+void quit(const union arg *arg)
 {
        running = False;
        return;
 }
 
-Monitor *recttomon(int x, int y, int w, int h)
+struct monitor *recttomon(int x, int y, int w, int h)
 {
-       Monitor *m, *r = selmon;
-       int a, area = 0;
+        struct monitor *m;
+       struct monitor *r;
+       int area;
+
+       r = selmon;
+       area = 0;
 
        for(m = mons; m; m = m->next) {
-               if((a = INTERSECT(x, y, w, h, m)) > area) {
+               int a;
+
+               a = INTERSECT(x, y, w, h, m);
+
+               if(a > area) {
                        area = a;
                        r = m;
                }
@@ -1810,9 +1835,9 @@ Monitor *recttomon(int x, int y, int w, int h)
        return(r);
 }
 
-void removesystrayicon(Client *i)
+void removesystrayicon(struct client *i)
 {
-       Client **ii;
+        struct client **ii;
 
        if(!showsystray || !i) {
                return;
@@ -1829,7 +1854,7 @@ void removesystrayicon(Client *i)
 }
 
 
-void resize(Client *c, int x, int y, int w, int h, Bool interact)
+void resize(struct 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);
@@ -1838,7 +1863,7 @@ void resize(Client *c, int x, int y, int w, int h, Bool interact)
        return;
 }
 
-void resizebarwin(Monitor *m)
+void resizebarwin(struct monitor *m)
 {
        unsigned int w = m->ww;
 
@@ -1851,7 +1876,7 @@ void resizebarwin(Monitor *m)
        return;
 }
 
-void resizeclient(Client *c, int x, int y, int w, int h)
+void resizeclient(struct client *c, int x, int y, int w, int h)
 {
        XWindowChanges wc;
 
@@ -1868,12 +1893,12 @@ void resizeclient(Client *c, int x, int y, int w, int h)
        return;
 }
 
-void resizemouse(const Arg *arg)
+void resizemouse(const union arg *arg)
 {
        int ocx, ocy;
        int nw, nh;
-       Client *c;
-       Monitor *m;
+        struct client *c;
+        struct monitor *m;
        XEvent ev;
 
        if(!(c = selmon->sel)) {
@@ -1932,7 +1957,7 @@ void resizemouse(const Arg *arg)
 void resizerequest(XEvent *e)
 {
        XResizeRequestEvent *ev = &e->xresizerequest;
-       Client *i;
+        struct client *i;
 
        if((i = wintosystrayicon(ev->window))) {
                updatesystrayicongeom(i, ev->width, ev->height);
@@ -1943,9 +1968,9 @@ void resizerequest(XEvent *e)
        return;
 }
 
-void restack(Monitor *m)
+void restack(struct monitor *m)
 {
-       Client *c;
+        struct client *c;
        XEvent ev;
        XWindowChanges wc;
 
@@ -2027,7 +2052,7 @@ void scan(void)
        return;
 }
 
-void sendmon(Client *c, Monitor *m)
+void sendmon(struct client *c, struct monitor *m)
 {
        if(c->mon == m) {
                return;
@@ -2046,7 +2071,7 @@ void sendmon(Client *c, Monitor *m)
        return;
 }
 
-void setclientstate(Client *c, long state)
+void setclientstate(struct client *c, long state)
 {
        long data[] = { state, None };
 
@@ -2094,7 +2119,7 @@ Bool sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d
        return(exists);
 }
 
-void setfocus(Client *c)
+void setfocus(struct client *c)
 {
        if(!c->neverfocus) {
                XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
@@ -2106,7 +2131,7 @@ void setfocus(Client *c)
        return;
 }
 
-void setfullscreen(Client *c, Bool fullscreen)
+void setfullscreen(struct client *c, Bool fullscreen)
 {
        if(fullscreen) {
                XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
@@ -2135,14 +2160,14 @@ void setfullscreen(Client *c, Bool fullscreen)
        return;
 }
 
-void setlayout(const Arg *arg)
+void setlayout(const union arg *arg)
 {
        if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) {
                selmon->sellt ^= 1;
        }
 
        if(arg && arg->v) {
-               selmon->lt[selmon->sellt] = (Layout *)arg->v;
+               selmon->lt[selmon->sellt] = (struct layout*)arg->v;
        }
 
        strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
@@ -2158,7 +2183,7 @@ void setlayout(const Arg *arg)
 
 #ifndef M10K
 /* arg > 1.0 will set mfact absolutly */
-void setmfact(const Arg *arg)
+void setmfact(const union arg *arg)
 {
        float f;
 
@@ -2245,7 +2270,7 @@ void setup(void)
        return;
 }
 
-void showhide(Client *c)
+void showhide(struct client *c)
 {
        if(!c) {
                return;
@@ -2278,7 +2303,7 @@ void sigchld(int unused)
        return;
 }
 
-void spawn(const Arg *arg)
+void spawn(const union arg *arg)
 {
        if(fork() == 0) {
                if(dpy) {
@@ -2296,7 +2321,7 @@ void spawn(const Arg *arg)
        return;
 }
 
-void tag(const Arg *arg)
+void tag(const union arg *arg)
 {
        if(selmon->sel && arg->ui & TAGMASK) {
                selmon->sel->tags = arg->ui & TAGMASK;
@@ -2307,7 +2332,7 @@ void tag(const Arg *arg)
        return;
 }
 
-void tagmon(const Arg *arg)
+void tagmon(const union arg *arg)
 {
        if(selmon->sel && mons->next) {
                sendmon(selmon->sel, dirtomon(arg->i));
@@ -2336,10 +2361,10 @@ int textnw(const char *text, unsigned int len)
        return(r.width / PANGO_SCALE);
 }
 
-void tile(Monitor *m)
+void tile(struct monitor *m)
 {
        unsigned int i, n, h, mw, my, ty;
-       Client *c;
+        struct client *c;
 
        for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
 
@@ -2368,9 +2393,9 @@ void tile(Monitor *m)
        return;
 }
 
-static int count_tiled_clients(Monitor *mon)
+static int count_tiled_clients(struct monitor *mon)
 {
-       Client *tiled;
+        struct client *tiled;
        int n;
 
        tiled = nexttiled(mon->clients);
@@ -2384,12 +2409,12 @@ static int count_tiled_clients(Monitor *mon)
        return(n);
 }
 
-static void bookshelf(Monitor *m)
+static void bookshelf(struct monitor *m)
 {
         int n, w, x;
        int extraw;
 
-        Client *c;
+        struct client *c;
 
        n = count_tiled_clients(m);
 
@@ -2430,12 +2455,12 @@ static void bookshelf(Monitor *m)
         return;
 }
 
-static void bookstack(Monitor *m)
+static void bookstack(struct monitor *m)
 {
         int n, h, y;
        int extrah;
 
-        Client *c;
+        struct client *c;
 
        /*
         * The logic is essentially the same as in bookshelf(), though
@@ -2464,7 +2489,7 @@ static void bookstack(Monitor *m)
 }
 
 #ifndef M10K
-void togglebar(const Arg *arg)
+void togglebar(const union arg *arg)
 {
        selmon->showbar = !selmon->showbar;
        updatebarpos(selmon);
@@ -2492,7 +2517,7 @@ void togglebar(const Arg *arg)
 }
 #endif /* ! M10K */
 
-void togglefloating(const Arg *arg)
+void togglefloating(const union arg *arg)
 {
        if(!selmon->sel) {
                return;
@@ -2510,7 +2535,7 @@ void togglefloating(const Arg *arg)
        return;
 }
 
-void toggletag(const Arg *arg)
+void toggletag(const union arg *arg)
 {
        unsigned int newtags;
 
@@ -2529,7 +2554,7 @@ void toggletag(const Arg *arg)
        return;
 }
 
-void toggleview(const Arg *arg)
+void toggleview(const union arg *arg)
 {
        unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
 
@@ -2542,7 +2567,7 @@ void toggleview(const Arg *arg)
        return;
 }
 
-void unfocus(Client *c, Bool setfocus)
+void unfocus(struct client *c, Bool setfocus)
 {
        if(!c) {
                return;
@@ -2558,9 +2583,9 @@ void unfocus(Client *c, Bool setfocus)
        return;
 }
 
-void unmanage(Client *c, Bool destroyed)
+void unmanage(struct client *c, Bool destroyed)
 {
-       Monitor *m = c->mon;
+       struct monitor *m = c->mon;
        XWindowChanges wc;
 
        /* The server grab construct avoids race conditions. */
@@ -2588,7 +2613,7 @@ void unmanage(Client *c, Bool destroyed)
 
 void unmapnotify(XEvent *e)
 {
-       Client *c;
+        struct client *c;
        XUnmapEvent *ev = &e->xunmap;
 
        if((c = wintoclient(ev->window))) {
@@ -2609,7 +2634,7 @@ void unmapnotify(XEvent *e)
 void updatebars(void)
 {
        unsigned int w;
-       Monitor *m;
+       struct monitor *m;
 
        XSetWindowAttributes wa = {
                .override_redirect = True,
@@ -2635,7 +2660,7 @@ void updatebars(void)
        return;
 }
 
-void updatebarpos(Monitor *m)
+void updatebarpos(struct monitor *m)
 {
        m->wy = m->my;
        m->wh = m->mh;
@@ -2658,8 +2683,8 @@ Bool updategeom(void)
 #ifdef XINERAMA
        if(XineramaIsActive(dpy)) {
                int i, j, n, nn;
-               Client *c;
-               Monitor *m;
+               struct client *c;
+               struct monitor *m;
                XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn);
                XineramaScreenInfo *unique = NULL;
 
@@ -2770,7 +2795,7 @@ void updatenumlockmask(void)
        return;
 }
 
-void updatesizehints(Client *c)
+void updatesizehints(struct client *c)
 {
        long msize;
        XSizeHints size;
@@ -2827,7 +2852,7 @@ void updatesizehints(Client *c)
        return;
 }
 
-void updatetitle(Client *c)
+void updatetitle(struct client *c)
 {
        if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) {
                gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
@@ -2851,7 +2876,7 @@ void updatestatus(void)
        return;
 }
 
-void updatesystrayicongeom(Client *i, int w, int h)
+void updatesystrayicongeom(struct client *i, int w, int h)
 {
        if(i) {
                i->h = bh;
@@ -2879,7 +2904,7 @@ void updatesystrayicongeom(Client *i, int w, int h)
        return;
 }
 
-void updatesystrayiconstate(Client *i, XPropertyEvent *ev)
+void updatesystrayiconstate(struct client *i, XPropertyEvent *ev)
 {
        long flags;
        int code = 0;
@@ -2912,7 +2937,7 @@ void updatesystrayiconstate(Client *i, XPropertyEvent *ev)
 void updatesystray(void)
 {
        XSetWindowAttributes wa;
-       Client *i;
+        struct client *i;
        unsigned int x = selmon->mx + selmon->mw;
        unsigned int w = 1;
 
@@ -2922,8 +2947,8 @@ void updatesystray(void)
 
        if(!systray) {
                /* init systray */
-               if(!(systray = (Systray *)calloc(1, sizeof(Systray)))) {
-                       die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
+               if(!(systray = (struct 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]);
@@ -2972,7 +2997,7 @@ void updatesystray(void)
        return;
 }
 
-void updatewindowtype(Client *c)
+void updatewindowtype(struct client *c)
 {
        Atom state = getatomprop(c, netatom[NetWMState]);
        Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
@@ -2988,7 +3013,7 @@ void updatewindowtype(Client *c)
        return;
 }
 
-void updatewmhints(Client *c)
+void updatewmhints(struct client *c)
 {
        XWMHints *wmh;
 
@@ -3012,7 +3037,7 @@ void updatewmhints(Client *c)
        return;
 }
 
-void view(const Arg *arg)
+void view(const union arg *arg)
 {
        if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) {
                return;
@@ -3030,10 +3055,10 @@ void view(const Arg *arg)
        return;
 }
 
-Client *wintoclient(Window w)
+struct client *wintoclient(Window w)
 {
-       Client *c;
-       Monitor *m;
+        struct client *c;
+       struct monitor *m;
 
        for(m = mons; m; m = m->next) {
                for(c = m->clients; c; c = c->next) {
@@ -3046,11 +3071,11 @@ Client *wintoclient(Window w)
        return(NULL);
 }
 
-Monitor *wintomon(Window w)
+struct monitor *wintomon(Window w)
 {
        int x, y;
-       Client *c;
-       Monitor *m;
+        struct client *c;
+       struct monitor *m;
 
        if(w == root && getrootptr(&x, &y)) {
                return(recttomon(x, y, 1, 1));
@@ -3069,9 +3094,9 @@ Monitor *wintomon(Window w)
        return(selmon);
 }
 
-Client *wintosystrayicon(Window w)
+struct client *wintosystrayicon(Window w)
 {
-       Client *i = NULL;
+        struct client *i = NULL;
 
        if(!showsystray || !w) {
                return(i);
@@ -3118,9 +3143,9 @@ int xerrorstart(Display *dpy, XErrorEvent *ee)
        return(-1);
 }
 
-void zoom(const Arg *arg)
+void zoom(const union arg *arg)
 {
-       Client *c = selmon->sel;
+        struct client *c = selmon->sel;
 
        if(!selmon->lt[selmon->sellt]->arrange ||
           (selmon->sel && selmon->sel->isfloating)) {