summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-11-08 22:48:43 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-11-08 22:48:43 +0100
commit3c91283ede911916452345d545435b08dce9d556 (patch)
treea4da41ed799abaffda5d7166a6c84d97cc4a4625
parente941181f464e43765bab98509ef6524e688a46ff (diff)
unboolification
-rw-r--r--config.def.h14
-rw-r--r--dwm.c141
2 files changed, 77 insertions, 78 deletions
diff --git a/config.def.h b/config.def.h
index 76073a5..7054c06 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,8 +13,8 @@ static const char selbgcolor[] = "#005577";
static const char selfgcolor[] = "#eeeeee";
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
-static const bool showbar = true; /* false means no bar */
-static const bool topbar = true; /* false means bottom bar */
+static const int showbar = 1; /* 0 means no bar */
+static const int topbar = 1; /* 0 means bottom bar */
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
@@ -25,14 +25,14 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, 0, true, -1 },
- { "Firefox", NULL, NULL, 1 << 8, false, -1 },
+ { "Gimp", NULL, NULL, 0, 1, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
};
/* layout(s) */
-static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
-static const int nmaster = 1; /* number of clients in master area */
-static const bool resizehints = true; /* true means respect size hints in tiled resizals */
+static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
+static const int nmaster = 1; /* number of clients in master area */
+static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const Layout layouts[] = {
/* symbol arrange function */
diff --git a/dwm.c b/dwm.c
index 9f99640..fb56d55 100644
--- a/dwm.c
+++ b/dwm.c
@@ -24,7 +24,6 @@
#include <locale.h>
#include <signal.h>
#include <stdarg.h>
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -93,7 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
- bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
Client *next;
Client *snext;
Monitor *mon;
@@ -123,8 +122,8 @@ struct Monitor {
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
- bool showbar;
- bool topbar;
+ int showbar;
+ int topbar;
Client *clients;
Client *sel;
Client *stack;
@@ -138,13 +137,13 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
- bool isfloating;
+ int isfloating;
int monitor;
} Rule;
/* function declarations */
static void applyrules(Client *c);
-static bool applysizehints(Client *c, int *x, int *y, int *w, int *h, bool interact);
+static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void attach(Client *c);
@@ -171,10 +170,10 @@ static void focus(Client *c);
static void focusin(XEvent *e);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
-static bool getrootptr(int *x, int *y);
+static int 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 int gettextprop(Window w, Atom atom, char *text, unsigned int size);
+static void grabbuttons(Client *c, int focused);
static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
@@ -190,17 +189,17 @@ static void pop(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 resize(Client *c, int x, int y, int w, int h, bool interact);
+static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
static void restack(Monitor *m);
static void run(void);
static void scan(void);
-static bool sendevent(Client *c, Atom proto);
+static int sendevent(Client *c, Atom proto);
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 setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
@@ -214,10 +213,10 @@ static void togglebar(const Arg *arg);
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 unfocus(Client *c, int setfocus);
+static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e);
-static bool updategeom(void);
+static int updategeom(void);
static void updatebarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
@@ -260,7 +259,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[UnmapNotify] = unmapnotify
};
static Atom wmatom[WMLast], netatom[NetLast];
-static bool running = true;
+static int running = 1;
static Cur *cursor[CurLast];
static ClrScheme scheme[SchemeLast];
static Display *dpy;
@@ -284,7 +283,7 @@ applyrules(Client *c) {
XClassHint ch = { NULL, NULL };
/* rule matching */
- c->isfloating = false;
+ c->isfloating = 0;
c->tags = 0;
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
@@ -310,9 +309,9 @@ applyrules(Client *c) {
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
}
-bool
-applysizehints(Client *c, int *x, int *y, int *w, int *h, bool interact) {
- bool baseismin;
+int
+applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact) {
+ int baseismin;
Monitor *m = c->mon;
/* set minimum possible */
@@ -419,7 +418,7 @@ buttonpress(XEvent *e) {
click = ClkRootWin;
/* focus monitor if necessary */
if((m = wintomon(ev->window)) && m != selmon) {
- unfocus(selmon->sel, true);
+ unfocus(selmon->sel, 1);
selmon = m;
focus(NULL);
}
@@ -470,7 +469,7 @@ cleanup(void) {
selmon->lt[selmon->sellt] = &foo;
for(m = mons; m; m = m->next)
while(m->stack)
- unmanage(m->stack, false);
+ unmanage(m->stack, 0);
XUngrabKey(dpy, AnyKey, AnyModifier, root);
while(mons)
cleanupmon(mons);
@@ -506,7 +505,7 @@ void
clearurgent(Client *c) {
XWMHints *wmh;
- c->isurgent = false;
+ c->isurgent = 0;
if(!(wmh = XGetWMHints(dpy, c->win)))
return;
wmh->flags &= ~XUrgencyHint;
@@ -557,7 +556,7 @@ void
configurenotify(XEvent *e) {
Monitor *m;
XConfigureEvent *ev = &e->xconfigure;
- bool dirty;
+ int dirty;
/* TODO: updategeom handling sucks, needs to be simplified */
if(ev->window == root) {
@@ -650,7 +649,7 @@ destroynotify(XEvent *e) {
XDestroyWindowEvent *ev = &e->xdestroywindow;
if((c = wintoclient(ev->window)))
- unmanage(c, true);
+ unmanage(c, 1);
}
void
@@ -761,7 +760,7 @@ enternotify(XEvent *e) {
c = wintoclient(ev->window);
m = c ? c->mon : wintomon(ev->window);
if(m != selmon) {
- unfocus(selmon->sel, true);
+ unfocus(selmon->sel, 1);
selmon = m;
}
else if(!c || c == selmon->sel)
@@ -784,7 +783,7 @@ focus(Client *c) {
for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
/* was if(selmon->sel) */
if(selmon->sel && selmon->sel != c)
- unfocus(selmon->sel, false);
+ unfocus(selmon->sel, 0);
if(c) {
if(c->mon != selmon)
selmon = c->mon;
@@ -792,7 +791,7 @@ focus(Client *c) {
clearurgent(c);
detachstack(c);
attachstack(c);
- grabbuttons(c, true);
+ grabbuttons(c, 1);
XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix);
setfocus(c);
}
@@ -820,7 +819,7 @@ focusmon(const Arg *arg) {
return;
if((m = dirtomon(arg->i)) == selmon)
return;
- unfocus(selmon->sel, false); /* s/true/false/ fixes input focus issues
+ unfocus(selmon->sel, 0); /* s/1/0/ fixes input focus issues
in gedit and anjuta */
selmon = m;
focus(NULL);
@@ -867,13 +866,13 @@ getatomprop(Client *c, Atom prop) {
return atom;
}
-bool
+int
getrootptr(int *x, int *y) {
int di;
unsigned int dui;
Window dummy;
- return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui) == True;
+ return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
}
long
@@ -893,18 +892,18 @@ getstate(Window w) {
return result;
}
-bool
+int
gettextprop(Window w, Atom atom, char *text, unsigned int size) {
char **list = NULL;
int n;
XTextProperty name;
if(!text || size == 0)
- return false;
+ return 0;
text[0] = '\0';
XGetTextProperty(dpy, w, &name, atom);
if(!name.nitems)
- return false;
+ return 0;
if(name.encoding == XA_STRING)
strncpy(text, (char *)name.value, size - 1);
else {
@@ -915,11 +914,11 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
}
text[size - 1] = '\0';
XFree(name.value);
- return true;
+ return 1;
}
void
-grabbuttons(Client *c, bool focused) {
+grabbuttons(Client *c, int focused) {
updatenumlockmask();
{
unsigned int i, j;
@@ -964,13 +963,13 @@ incnmaster(const Arg *arg) {
}
#ifdef XINERAMA
-static bool
+static int
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;
+ return 0;
+ return 1;
}
#endif /* XINERAMA */
@@ -1046,7 +1045,7 @@ manage(Window w, XWindowAttributes *wa) {
updatesizehints(c);
updatewmhints(c);
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
- grabbuttons(c, false);
+ grabbuttons(c, 0);
if(!c->isfloating)
c->isfloating = c->oldstate = trans != None || c->isfixed;
if(c->isfloating)
@@ -1058,7 +1057,7 @@ manage(Window w, XWindowAttributes *wa) {
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
setclientstate(c, NormalState);
if (c->mon == selmon)
- unfocus(selmon->sel, false);
+ unfocus(selmon->sel, 0);
c->mon->sel = c;
arrange(c->mon);
XMapWindow(dpy, c->win);
@@ -1098,7 +1097,7 @@ monocle(Monitor *m) {
if(n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
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);
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
}
void
@@ -1110,7 +1109,7 @@ motionnotify(XEvent *e) {
if(ev->window != root)
return;
if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
- unfocus(selmon->sel, true);
+ unfocus(selmon->sel, 1);
selmon = m;
focus(NULL);
}
@@ -1167,7 +1166,7 @@ movemouse(const Arg *arg) {
togglefloating(NULL);
}
if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, nx, ny, c->w, c->h, true);
+ resize(c, nx, ny, c->w, c->h, 1);
break;
}
} while(ev.type != ButtonRelease);
@@ -1231,7 +1230,7 @@ propertynotify(XEvent *e) {
void
quit(const Arg *arg) {
- running = false;
+ running = 0;
}
Monitor *
@@ -1248,7 +1247,7 @@ recttomon(int x, int y, int w, int h) {
}
void
-resize(Client *c, int x, int y, int w, int h, bool interact) {
+resize(Client *c, int x, int y, int w, int h, int interact) {
if(applysizehints(c, &x, &y, &w, &h, interact))
resizeclient(c, x, y, w, h);
}
@@ -1309,7 +1308,7 @@ resizemouse(const Arg *arg) {
togglefloating(NULL);
}
if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, nw, nh, true);
+ resize(c, c->x, c->y, nw, nh, 1);
break;
}
} while(ev.type != ButtonRelease);
@@ -1387,7 +1386,7 @@ void
sendmon(Client *c, Monitor *m) {
if(c->mon == m)
return;
- unfocus(c, true);
+ unfocus(c, 1);
detach(c);
detachstack(c);
c->mon = m;
@@ -1406,11 +1405,11 @@ setclientstate(Client *c, long state) {
PropModeReplace, (unsigned char *)data, 2);
}
-bool
+int
sendevent(Client *c, Atom proto) {
int n;
Atom *protocols;
- bool exists = false;
+ int exists = 0;
XEvent ev;
if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
@@ -1442,22 +1441,22 @@ setfocus(Client *c) {
}
void
-setfullscreen(Client *c, bool fullscreen) {
+setfullscreen(Client *c, int fullscreen) {
if(fullscreen && !c->isfullscreen) {
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
- c->isfullscreen = true;
+ c->isfullscreen = 1;
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
- c->isfloating = true;
+ c->isfloating = 1;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
else if(!fullscreen && c->isfullscreen){
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0);
- c->isfullscreen = false;
+ c->isfullscreen = 0;
c->isfloating = c->oldstate;
c->bw = c->oldbw;
c->x = c->oldx;
@@ -1562,7 +1561,7 @@ showhide(Client *c) {
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)
- resize(c, c->x, c->y, c->w, c->h, false);
+ resize(c, c->x, c->y, c->w, c->h, 0);
showhide(c->snext);
}
else { /* hide clients bottom up */
@@ -1625,12 +1624,12 @@ tile(Monitor *m) {
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);
+ resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
my += HEIGHT(c);
}
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);
+ resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
ty += HEIGHT(c);
}
}
@@ -1652,7 +1651,7 @@ togglefloating(const Arg *arg) {
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
if(selmon->sel->isfloating)
resize(selmon->sel, selmon->sel->x, selmon->sel->y,
- selmon->sel->w, selmon->sel->h, false);
+ selmon->sel->w, selmon->sel->h, 0);
arrange(selmon);
}
@@ -1682,10 +1681,10 @@ toggleview(const Arg *arg) {
}
void
-unfocus(Client *c, bool setfocus) {
+unfocus(Client *c, int setfocus) {
if(!c)
return;
- grabbuttons(c, false);
+ grabbuttons(c, 0);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix);
if(setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@@ -1694,7 +1693,7 @@ unfocus(Client *c, bool setfocus) {
}
void
-unmanage(Client *c, bool destroyed) {
+unmanage(Client *c, int destroyed) {
Monitor *m = c->mon;
XWindowChanges wc;
@@ -1727,7 +1726,7 @@ unmapnotify(XEvent *e) {
if(ev->send_event)
setclientstate(c, WithdrawnState);
else
- unmanage(c, false);
+ unmanage(c, 0);
}
}
@@ -1776,9 +1775,9 @@ updateclientlist() {
(unsigned char *) &(c->win), 1);
}
-bool
+int
updategeom(void) {
- bool dirty = false;
+ int dirty = 0;
#ifdef XINERAMA
if(XineramaIsActive(dpy)) {
@@ -1809,7 +1808,7 @@ updategeom(void) {
|| (unique[i].x_org != m->mx || unique[i].y_org != m->my
|| unique[i].width != m->mw || unique[i].height != m->mh))
{
- dirty = true;
+ dirty = 1;
m->num = i;
m->mx = m->wx = unique[i].x_org;
m->my = m->wy = unique[i].y_org;
@@ -1822,7 +1821,7 @@ updategeom(void) {
for(i = nn; i < n; i++) {
for(m = mons; m && m->next; m = m->next);
while(m->clients) {
- dirty = true;
+ dirty = 1;
c = m->clients;
m->clients = c->next;
detachstack(c);
@@ -1844,7 +1843,7 @@ updategeom(void) {
if(!mons)
mons = createmon();
if(mons->mw != sw || mons->mh != sh) {
- dirty = true;
+ dirty = 1;
mons->mw = mons->ww = sw;
mons->mh = mons->wh = sh;
updatebarpos(mons);
@@ -1943,9 +1942,9 @@ updatewindowtype(Client *c) {
Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
if(state == netatom[NetWMFullscreen])
- setfullscreen(c, true);
+ setfullscreen(c, 1);
if(wtype == netatom[NetWMWindowTypeDialog])
- c->isfloating = true;
+ c->isfloating = 1;
}
void
@@ -1958,11 +1957,11 @@ updatewmhints(Client *c) {
XSetWMHints(dpy, c->win, wmh);
}
else
- c->isurgent = (wmh->flags & XUrgencyHint) ? true : false;
+ c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0;
if(wmh->flags & InputHint)
c->neverfocus = !wmh->input;
else
- c->neverfocus = false;
+ c->neverfocus = 0;
XFree(wmh);
}
}