X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=e6ba20c981cbaeab1fdeb1edce2a55ba02559613;hb=0ea0343a631b62f2a9d9c5b279d3e368ec47c28a;hp=1015017f1297af147482d917412a873595d9bb55;hpb=e7508783e85aba0ce4ab09b0dd76c40342113aed;p=dwm.git diff --git a/main.c b/main.c index 1015017..e6ba20c 100644 --- a/main.c +++ b/main.c @@ -21,7 +21,6 @@ char stext[256]; int screen, sx, sy, sw, sh, wax, way, waw, wah; unsigned int bh, ntags, numlockmask; Atom wmatom[WMLast], netatom[NetLast]; -Bool running = True; Bool *seltag; Bool selscreen = True; Client *clients = NULL; @@ -36,6 +35,7 @@ Window root, barwin; static int (*xerrorxlib)(Display *, XErrorEvent *); static Bool otherwm, readin; +static Bool running = True; static void cleanup(void) { @@ -62,7 +62,7 @@ cleanup(void) { } static unsigned long -getcolor(const char *colstr) { +initcolor(const char *colstr) { Colormap cmap = DefaultColormap(dpy, screen); XColor color; @@ -72,27 +72,7 @@ getcolor(const char *colstr) { } static void -scan(void) { - unsigned int i, num; - Window *wins, d1, d2; - XWindowAttributes wa; - - wins = NULL; - if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { - for(i = 0; i < num; i++) { - if(!XGetWindowAttributes(dpy, wins[i], &wa) - || wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) - continue; - if(wa.map_state == IsViewable) - manage(wins[i], &wa); - } - } - if(wins) - XFree(wins); -} - -static void -setfont(const char *fontstr) { +initfont(const char *fontstr) { char *def, **missing; int i, n; @@ -133,6 +113,26 @@ setfont(const char *fontstr) { } static void +scan(void) { + unsigned int i, num; + Window *wins, d1, d2; + XWindowAttributes wa; + + wins = NULL; + if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { + for(i = 0; i < num; i++) { + if(!XGetWindowAttributes(dpy, wins[i], &wa) + || wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) + continue; + if(wa.map_state == IsViewable) + manage(wins[i], &wa); + } + } + if(wins) + XFree(wins); +} + +static void setup(void) { int i, j; unsigned int mask; @@ -173,13 +173,13 @@ setup(void) { seltag = emallocz(sizeof(Bool) * ntags); seltag[0] = True; /* style */ - dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); - dc.norm[ColBG] = getcolor(NORMBGCOLOR); - dc.norm[ColFG] = getcolor(NORMFGCOLOR); - dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); - dc.sel[ColBG] = getcolor(SELBGCOLOR); - dc.sel[ColFG] = getcolor(SELFGCOLOR); - setfont(FONT); + dc.norm[ColBorder] = initcolor(NORMBORDERCOLOR); + dc.norm[ColBG] = initcolor(NORMBGCOLOR); + dc.norm[ColFG] = initcolor(NORMFGCOLOR); + dc.sel[ColBorder] = initcolor(SELBORDERCOLOR); + dc.sel[ColBG] = initcolor(SELBGCOLOR); + dc.sel[ColFG] = initcolor(SELFGCOLOR); + initfont(FONT); /* geometry */ sx = sy = 0; sw = DisplayWidth(dpy, screen); @@ -236,7 +236,7 @@ sendevent(Window w, Atom a, long value) { } void -quit(Arg *arg) { +quit(const char *arg) { readin = running = False; } @@ -325,12 +325,11 @@ main(int argc, char *argv[]) { } drawstatus(); } - if(FD_ISSET(xfd, &rd)) - while(XPending(dpy)) { - XNextEvent(dpy, &ev); - if(handler[ev.type]) - (handler[ev.type])(&ev); /* call handler */ - } + while(XPending(dpy)) { + XNextEvent(dpy, &ev); + if(handler[ev.type]) + (handler[ev.type])(&ev); /* call handler */ + } } cleanup(); XCloseDisplay(dpy);