X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dwm.c;h=5d64141076435ba30f9a02bb6749197c0f46ab4e;hb=43e82adf0dc37411fdcc6406b3cdf5d572387b9f;hp=7ca1ace17bda76c0260ec0b85e3d29ff9125174d;hpb=5364697914fd4272fc1a6494b4fc522d2935427a;p=dwm.git diff --git a/dwm.c b/dwm.c index 7ca1ace..5d64141 100644 --- a/dwm.c +++ b/dwm.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ #ifdef XINERAMA #include #endif /* XINERAMA */ +#include #include "drw.h" #include "util.h" @@ -54,17 +56,17 @@ #define WIDTH(X) ((X)->w + 2 * (X)->bw) #define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define TAGMASK ((1 << LENGTH(tags)) - 1) -#define TEXTW(X) (drw_font_getexts_width(drw->font, X, strlen(X)) + drw->font->h) +#define TEXTW(X) (drw_text(drw, 0, 0, 0, 0, (X), 0) + drw->fonts[0]->h) /* enums */ -enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ +enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ +enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType, - NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ + NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, - ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ + ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ typedef union { int i; @@ -91,7 +93,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; + bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; Client *next; Client *snext; Monitor *mon; @@ -121,8 +123,8 @@ struct Monitor { unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; - Bool showbar; - Bool topbar; + bool showbar; + bool topbar; Client *clients; Client *sel; Client *stack; @@ -136,13 +138,13 @@ typedef struct { 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); @@ -169,10 +171,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 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); @@ -188,17 +190,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, 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); @@ -212,10 +214,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, 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); @@ -258,13 +260,11 @@ static void (*handler[LASTEvent]) (XEvent *) = { [UnmapNotify] = unmapnotify }; static Atom wmatom[WMLast], netatom[NetLast]; -static Bool running = True; +static bool running = true; static Cur *cursor[CurLast]; -static Theme thmnorm[ColLast]; -static Theme thmsel[ColLast]; +static ClrScheme scheme[SchemeLast]; static Display *dpy; static Drw *drw; -static Fnt *fnt; static Monitor *mons, *selmon; static Window root; @@ -284,7 +284,8 @@ applyrules(Client *c) { 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; @@ -309,9 +310,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; +bool +applysizehints(Client *c, int *x, int *y, int *w, int *h, bool interact) { + bool baseismin; Monitor *m = c->mon; /* set minimum possible */ @@ -418,7 +419,7 @@ buttonpress(XEvent *e) { 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); } @@ -463,25 +464,23 @@ cleanup(void) { Arg a = {.ui = ~0}; Layout foo = { "", NULL }; Monitor *m; + size_t i; view(&a); 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); - drw_cur_free(drw, cursor[CurNormal]); - drw_cur_free(drw, cursor[CurResize]); - drw_cur_free(drw, cursor[CurMove]); - drw_font_free(dpy, fnt); - drw_clr_free(thmnorm->border); - drw_clr_free(thmnorm->bg); - drw_clr_free(thmnorm->fg); - drw_clr_free(thmsel->border); - drw_clr_free(thmsel->bg); - drw_clr_free(thmsel->fg); + for(i = 0; i < CurLast; i++) + drw_cur_free(drw, cursor[i]); + for(i = 0; i < SchemeLast; i++) { + drw_clr_free(scheme[i].border); + drw_clr_free(scheme[i].bg); + drw_clr_free(scheme[i].fg); + } drw_free(drw); XSync(dpy, False); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); @@ -507,7 +506,7 @@ void clearurgent(Client *c) { XWMHints *wmh; - c->isurgent = False; + c->isurgent = false; if(!(wmh = XGetWMHints(dpy, c->win))) return; wmh->flags &= ~XUrgencyHint; @@ -558,9 +557,9 @@ void configurenotify(XEvent *e) { Monitor *m; XConfigureEvent *ev = &e->xconfigure; - Bool dirty; + bool dirty; - // TODO: updategeom handling sucks, needs to be simplified + /* TODO: updategeom handling sucks, needs to be simplified */ if(ev->window == root) { dirty = (sw != ev->width || sh != ev->height); sw = ev->width; @@ -633,8 +632,7 @@ Monitor * createmon(void) { Monitor *m; - if(!(m = (Monitor *)calloc(1, sizeof(Monitor)))) - die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); + m = ecalloc(1, sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; m->mfact = mfact; m->nmaster = nmaster; @@ -652,7 +650,7 @@ destroynotify(XEvent *e) { XDestroyWindowEvent *ev = &e->xdestroywindow; if((c = wintoclient(ev->window))) - unmanage(c, True); + unmanage(c, true); } void @@ -693,10 +691,12 @@ dirtomon(int dir) { void drawbar(Monitor *m) { - int x, xx, w; + int x, xx, w, dx; unsigned int i, occ = 0, urg = 0; Client *c; + dx = (drw->fonts[0]->ascent + drw->fonts[0]->descent + 2) / 4; + for(c = m->clients; c; c = c->next) { occ |= c->tags; if(c->isurgent) @@ -705,14 +705,14 @@ drawbar(Monitor *m) { x = 0; for(i = 0; i < LENGTH(tags); i++) { w = TEXTW(tags[i]); - drw_settheme(drw, m->tagset[m->seltags] & 1 << i ? thmsel : thmnorm); + drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &scheme[SchemeSel] : &scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, tags[i], urg & 1 << i); - drw_rect(drw, x, 0, w, bh, m == selmon && selmon->sel && selmon->sel->tags & 1 << i, + drw_rect(drw, x + 1, 1, dx, dx, m == selmon && selmon->sel && selmon->sel->tags & 1 << i, occ & 1 << i, urg & 1 << i); x += w; } w = blw = TEXTW(m->ltsymbol); - drw_settheme(drw, thmnorm); + drw_setscheme(drw, &scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, m->ltsymbol, 0); x += w; xx = x; @@ -730,13 +730,13 @@ drawbar(Monitor *m) { if((w = x - xx) > bh) { x = xx; if(m->sel) { - drw_settheme(drw, m == selmon ? thmsel : thmnorm); + drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, m->sel->name, 0); - drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, 0); + drw_rect(drw, x + 1, 1, dx, dx, m->sel->isfixed, m->sel->isfloating, 0); } else { - drw_settheme(drw, thmnorm); - drw_text(drw, x, 0, w, bh, NULL, 0); + drw_setscheme(drw, &scheme[SchemeNorm]); + drw_rect(drw, x, 0, w, bh, 1, 0, 1); } } drw_map(drw, m->barwin, 0, 0, m->ww, bh); @@ -761,7 +761,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, true); selmon = m; } else if(!c || c == selmon->sel) @@ -784,7 +784,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, false); if(c) { if(c->mon != selmon) selmon = c->mon; @@ -792,8 +792,8 @@ focus(Client *c) { clearurgent(c); detachstack(c); attachstack(c); - grabbuttons(c, True); - XSetWindowBorder(dpy, c->win, thmsel->border->rgb); + grabbuttons(c, true); + XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix); setfocus(c); } else { @@ -820,7 +820,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, false); /* s/true/false/ fixes input focus issues in gedit and anjuta */ selmon = m; focus(NULL); @@ -867,13 +867,13 @@ getatomprop(Client *c, Atom prop) { 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 @@ -893,18 +893,18 @@ getstate(Window w) { 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 { @@ -915,11 +915,11 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) { } text[size - 1] = '\0'; XFree(name.value); - return True; + return true; } void -grabbuttons(Client *c, Bool focused) { +grabbuttons(Client *c, bool focused) { updatenumlockmask(); { unsigned int i, j; @@ -964,13 +964,13 @@ incnmaster(const Arg *arg) { } #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 */ @@ -1010,8 +1010,7 @@ manage(Window w, XWindowAttributes *wa) { Window trans = None; XWindowChanges wc; - if(!(c = calloc(1, sizeof(Client)))) - die("fatal: could not malloc() %u bytes\n", sizeof(Client)); + c = ecalloc(1, sizeof(Client)); c->win = w; updatetitle(c); if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { @@ -1041,13 +1040,13 @@ manage(Window w, XWindowAttributes *wa) { wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, thmnorm->border->rgb); + XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->pix); configure(c); /* propagates border_width, if size doesn't change */ updatewindowtype(c); 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) @@ -1059,7 +1058,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, false); c->mon->sel = c; arrange(c->mon); XMapWindow(dpy, c->win); @@ -1099,7 +1098,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, false); } void @@ -1111,7 +1110,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, true); selmon = m; focus(NULL); } @@ -1124,6 +1123,7 @@ movemouse(const Arg *arg) { Client *c; Monitor *m; XEvent ev; + Time lasttime = 0; if(!(c = selmon->sel)) return; @@ -1146,6 +1146,10 @@ movemouse(const Arg *arg) { handler[ev.type](&ev); break; case MotionNotify: + if ((ev.xmotion.time - lasttime) <= (1000 / 60)) + continue; + lasttime = ev.xmotion.time; + nx = ocx + (ev.xmotion.x - x); ny = ocy + (ev.xmotion.y - y); if(nx >= selmon->wx && nx <= selmon->wx + selmon->ww @@ -1163,7 +1167,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, true); break; } } while(ev.type != ButtonRelease); @@ -1227,7 +1231,7 @@ propertynotify(XEvent *e) { void quit(const Arg *arg) { - running = False; + running = false; } Monitor * @@ -1244,7 +1248,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, bool interact) { if(applysizehints(c, &x, &y, &w, &h, interact)) resizeclient(c, x, y, w, h); } @@ -1265,11 +1269,11 @@ resizeclient(Client *c, int x, int y, int w, int h) { void resizemouse(const Arg *arg) { - int ocx, ocy; - int nw, nh; + int ocx, ocy, nw, nh; Client *c; Monitor *m; XEvent ev; + Time lasttime = 0; if(!(c = selmon->sel)) return; @@ -1291,6 +1295,10 @@ resizemouse(const Arg *arg) { handler[ev.type](&ev); break; case MotionNotify: + if ((ev.xmotion.time - lasttime) <= (1000 / 60)) + continue; + lasttime = ev.xmotion.time; + nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); if(c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww @@ -1301,7 +1309,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, true); break; } } while(ev.type != ButtonRelease); @@ -1379,7 +1387,7 @@ void sendmon(Client *c, Monitor *m) { if(c->mon == m) return; - unfocus(c, True); + unfocus(c, true); detach(c); detachstack(c); c->mon = m; @@ -1398,11 +1406,11 @@ setclientstate(Client *c, long state) { 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)) { @@ -1434,22 +1442,22 @@ setfocus(Client *c) { } void -setfullscreen(Client *c, Bool fullscreen) { - if(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 { + 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; @@ -1497,13 +1505,14 @@ setup(void) { /* init screen */ screen = DefaultScreen(dpy); - root = RootWindow(dpy, screen); - fnt = drw_font_create(dpy, font); sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); - bh = fnt->h + 2; + root = RootWindow(dpy, screen); drw = drw_create(dpy, screen, root, sw, sh); - drw_setfont(drw, fnt); + drw_load_fonts(drw, fonts, LENGTH(fonts)); + if (!drw->fontcount) + die("no fonts could be loaded.\n"); + bh = drw->fonts[0]->h + 2; updategeom(); /* init atoms */ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); @@ -1523,12 +1532,12 @@ setup(void) { cursor[CurResize] = drw_cur_create(drw, XC_sizing); cursor[CurMove] = drw_cur_create(drw, XC_fleur); /* init appearance */ - thmnorm->border = drw_clr_create(drw, normbordercolor); - thmnorm->bg = drw_clr_create(drw, normbgcolor); - thmnorm->fg = drw_clr_create(drw, normfgcolor); - thmsel->border = drw_clr_create(drw, selbordercolor); - thmsel->bg = drw_clr_create(drw, selbgcolor); - thmsel->fg = drw_clr_create(drw, selfgcolor); + scheme[SchemeNorm].border = drw_clr_create(drw, normbordercolor); + scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor); + scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor); + scheme[SchemeSel].border = drw_clr_create(drw, selbordercolor); + scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor); + scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor); /* init bars */ updatebars(); updatestatus(); @@ -1543,6 +1552,7 @@ setup(void) { XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); XSelectInput(dpy, root, wa.event_mask); grabkeys(); + focus(NULL); } void @@ -1552,7 +1562,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, false); showhide(c->snext); } else { /* hide clients bottom up */ @@ -1564,12 +1574,14 @@ showhide(Client *c) { void sigchld(int unused) { if(signal(SIGCHLD, sigchld) == SIG_ERR) - die("Can't install SIGCHLD handler"); + die("can't install SIGCHLD handler:"); while(0 < waitpid(-1, NULL, WNOHANG)); } void spawn(const Arg *arg) { + if(arg->v == dmenucmd) + dmenumon[0] = '0' + selmon->num; if(fork() == 0) { if(dpy) close(ConnectionNumber(dpy)); @@ -1613,12 +1625,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), 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); } } @@ -1640,7 +1652,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, false); arrange(selmon); } @@ -1670,11 +1682,11 @@ toggleview(const Arg *arg) { } void -unfocus(Client *c, Bool setfocus) { +unfocus(Client *c, bool setfocus) { if(!c) return; - grabbuttons(c, False); - XSetWindowBorder(dpy, c->win, thmnorm->border->rgb); + grabbuttons(c, false); + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix); if(setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XDeleteProperty(dpy, root, netatom[NetActiveWindow]); @@ -1682,7 +1694,7 @@ unfocus(Client *c, Bool setfocus) { } void -unmanage(Client *c, Bool destroyed) { +unmanage(Client *c, bool destroyed) { Monitor *m = c->mon; XWindowChanges wc; @@ -1715,7 +1727,7 @@ unmapnotify(XEvent *e) { if(ev->send_event) setclientstate(c, WithdrawnState); else - unmanage(c, False); + unmanage(c, false); } } @@ -1764,9 +1776,9 @@ updateclientlist() { (unsigned char *) &(c->win), 1); } -Bool +bool updategeom(void) { - Bool dirty = False; + bool dirty = false; #ifdef XINERAMA if(XineramaIsActive(dpy)) { @@ -1778,8 +1790,7 @@ updategeom(void) { for(n = 0, m = mons; m; m = m->next, n++); /* only consider unique geometries as separate screens */ - if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn))) - die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn); + unique = ecalloc(nn, sizeof(XineramaScreenInfo)); for(i = 0, j = 0; i < nn; i++) if(isuniquegeom(unique, j, &info[i])) memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo)); @@ -1798,7 +1809,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 = true; m->num = i; m->mx = m->wx = unique[i].x_org; m->my = m->wy = unique[i].y_org; @@ -1811,7 +1822,7 @@ updategeom(void) { 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); @@ -1833,7 +1844,7 @@ updategeom(void) { 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); @@ -1932,9 +1943,9 @@ updatewindowtype(Client *c) { 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 @@ -1947,11 +1958,11 @@ updatewmhints(Client *c) { 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); } } @@ -2044,7 +2055,7 @@ zoom(const Arg *arg) { int main(int argc, char *argv[]) { if(argc == 2 && !strcmp("-v", argv[1])) - die("dwm-"VERSION", © 2006-2012 dwm engineers, see LICENSE for details\n"); + die("dwm-"VERSION", © 2006-2015 dwm engineers, see LICENSE for details\n"); else if(argc != 1) die("usage: dwm [-v]\n"); if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())