#include <locale.h>
#include <stdarg.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
- Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
Client *next;
Client *snext;
Monitor *mon;
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
- Bool showbar;
- Bool topbar;
+ bool showbar;
+ bool topbar;
Client *clients;
Client *sel;
Client *stack;
const char *instance;
const char *title;
unsigned int tags;
- Bool isfloating;
+ bool 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 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 focusin(XEvent *e);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
-static Bool getrootptr(int *x, int *y);
+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 bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
+static void grabbuttons(Client *c, bool focused);
static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
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, bool 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 bool 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, bool fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
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, bool setfocus);
+static void unmanage(Client *c, bool destroyed);
static void unmapnotify(XEvent *e);
-static Bool updategeom(void);
+static bool updategeom(void);
static void updatebarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
[UnmapNotify] = unmapnotify
};
static Atom wmatom[WMLast], netatom[NetLast];
-static Bool running = True;
+static bool running = true;
static Cur *cursor[CurLast];
static ClrScheme scheme[SchemeLast];
static Display *dpy;
XClassHint ch = { NULL, NULL };
/* rule matching */
- c->isfloating = c->tags = 0;
+ c->isfloating = false;
+ c->tags = 0;
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
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;
+bool
+applysizehints(Client *c, int *x, int *y, int *w, int *h, bool interact) {
+ bool baseismin;
Monitor *m = c->mon;
/* set minimum possible */
click = ClkRootWin;
/* focus monitor if necessary */
if((m = wintomon(ev->window)) && m != selmon) {
- unfocus(selmon->sel, True);
+ unfocus(selmon->sel, true);
selmon = m;
focus(NULL);
}
selmon->lt[selmon->sellt] = &foo;
for(m = mons; m; m = m->next)
while(m->stack)
- unmanage(m->stack, False);
+ unmanage(m->stack, false);
XUngrabKey(dpy, AnyKey, AnyModifier, root);
while(mons)
cleanupmon(mons);
clearurgent(Client *c) {
XWMHints *wmh;
- c->isurgent = False;
+ c->isurgent = false;
if(!(wmh = XGetWMHints(dpy, c->win)))
return;
wmh->flags &= ~XUrgencyHint;
configurenotify(XEvent *e) {
Monitor *m;
XConfigureEvent *ev = &e->xconfigure;
- Bool dirty;
+ bool dirty;
/* TODO: updategeom handling sucks, needs to be simplified */
if(ev->window == root) {
XDestroyWindowEvent *ev = &e->xdestroywindow;
if((c = wintoclient(ev->window)))
- unmanage(c, True);
+ unmanage(c, true);
}
void
c = wintoclient(ev->window);
m = c ? c->mon : wintomon(ev->window);
if(m != selmon) {
- unfocus(selmon->sel, True);
+ unfocus(selmon->sel, true);
selmon = m;
}
else if(!c || c == selmon->sel)
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, false);
if(c) {
if(c->mon != selmon)
selmon = c->mon;
clearurgent(c);
detachstack(c);
attachstack(c);
- grabbuttons(c, True);
+ grabbuttons(c, true);
XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix);
setfocus(c);
}
return;
if((m = dirtomon(arg->i)) == selmon)
return;
- unfocus(selmon->sel, False); /* s/True/False/ fixes input focus issues
+ unfocus(selmon->sel, false); /* s/true/false/ fixes input focus issues
in gedit and anjuta */
selmon = m;
focus(NULL);
return atom;
}
-Bool
+bool
getrootptr(int *x, int *y) {
int di;
unsigned int dui;
Window dummy;
- return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
+ return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui) == True;
}
long
return result;
}
-Bool
+bool
gettextprop(Window w, Atom atom, char *text, unsigned int size) {
char **list = NULL;
int n;
XTextProperty name;
if(!text || size == 0)
- return False;
+ return false;
text[0] = '\0';
XGetTextProperty(dpy, w, &name, atom);
if(!name.nitems)
- return False;
+ return false;
if(name.encoding == XA_STRING)
strncpy(text, (char *)name.value, size - 1);
else {
}
text[size - 1] = '\0';
XFree(name.value);
- return True;
+ return true;
}
void
-grabbuttons(Client *c, Bool focused) {
+grabbuttons(Client *c, bool focused) {
updatenumlockmask();
{
unsigned int i, j;
}
#ifdef XINERAMA
-static Bool
+static bool
isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) {
while(n--)
if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org
&& unique[n].width == info->width && unique[n].height == info->height)
- return False;
- return True;
+ return false;
+ return true;
}
#endif /* XINERAMA */
updatesizehints(c);
updatewmhints(c);
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
- grabbuttons(c, False);
+ grabbuttons(c, false);
if(!c->isfloating)
c->isfloating = c->oldstate = trans != None || c->isfixed;
if(c->isfloating)
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, false);
c->mon->sel = c;
arrange(c->mon);
XMapWindow(dpy, c->win);
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, false);
}
void
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, true);
selmon = m;
focus(NULL);
}
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, true);
break;
}
} while(ev.type != ButtonRelease);
void
quit(const Arg *arg) {
- running = False;
+ running = false;
}
Monitor *
}
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, bool interact) {
if(applysizehints(c, &x, &y, &w, &h, interact))
resizeclient(c, x, y, w, h);
}
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, true);
break;
}
} while(ev.type != ButtonRelease);
sendmon(Client *c, Monitor *m) {
if(c->mon == m)
return;
- unfocus(c, True);
+ unfocus(c, true);
detach(c);
detachstack(c);
c->mon = m;
PropModeReplace, (unsigned char *)data, 2);
}
-Bool
+bool
sendevent(Client *c, Atom proto) {
int n;
Atom *protocols;
- Bool exists = False;
+ bool exists = false;
XEvent ev;
if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
}
void
-setfullscreen(Client *c, Bool fullscreen) {
+setfullscreen(Client *c, bool 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 = true;
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
- c->isfloating = True;
+ c->isfloating = true;
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 = false;
c->isfloating = c->oldstate;
c->bw = c->oldbw;
c->x = c->oldx;
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, false);
showhide(c->snext);
}
else { /* hide clients bottom up */
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), false);
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), false);
ty += HEIGHT(c);
}
}
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, false);
arrange(selmon);
}
}
void
-unfocus(Client *c, Bool setfocus) {
+unfocus(Client *c, bool setfocus) {
if(!c)
return;
- grabbuttons(c, False);
+ grabbuttons(c, false);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix);
if(setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
}
void
-unmanage(Client *c, Bool destroyed) {
+unmanage(Client *c, bool destroyed) {
Monitor *m = c->mon;
XWindowChanges wc;
if(ev->send_event)
setclientstate(c, WithdrawnState);
else
- unmanage(c, False);
+ unmanage(c, false);
}
}
(unsigned char *) &(c->win), 1);
}
-Bool
+bool
updategeom(void) {
- Bool dirty = False;
+ bool dirty = false;
#ifdef XINERAMA
if(XineramaIsActive(dpy)) {
|| (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 = true;
m->num = i;
m->mx = m->wx = unique[i].x_org;
m->my = m->wy = unique[i].y_org;
for(i = nn; i < n; i++) {
for(m = mons; m && m->next; m = m->next);
while(m->clients) {
- dirty = True;
+ dirty = true;
c = m->clients;
m->clients = c->next;
detachstack(c);
if(!mons)
mons = createmon();
if(mons->mw != sw || mons->mh != sh) {
- dirty = True;
+ dirty = true;
mons->mw = mons->ww = sw;
mons->mh = mons->wh = sh;
updatebarpos(mons);
Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
if(state == netatom[NetWMFullscreen])
- setfullscreen(c, True);
+ setfullscreen(c, true);
if(wtype == netatom[NetWMWindowTypeDialog])
- c->isfloating = True;
+ c->isfloating = true;
}
void
XSetWMHints(dpy, c->win, wmh);
}
else
- c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
+ c->isurgent = (wmh->flags & XUrgencyHint) ? true : false;
if(wmh->flags & InputHint)
c->neverfocus = !wmh->input;
else
- c->neverfocus = False;
+ c->neverfocus = false;
XFree(wmh);
}
}