X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=main.c;h=1bc4068b1eb06ad3a98492ba926b6143abb2fb7a;hp=b34859826148fe991ffd12e22ff5481f338bd031;hb=b43989207a949cbc17182b451aa527afe542c98f;hpb=b6ad663f87b195b1494798030f826cb2fbc71a23 diff --git a/main.c b/main.c index b348598..1bc4068 100644 --- a/main.c +++ b/main.c @@ -18,16 +18,24 @@ /* static */ static int (*xerrorxlib)(Display *, XErrorEvent *); -static Bool otherwm; +static Bool otherwm, readin; static void cleanup() { + close(STDIN_FILENO); while(sel) { resize(sel, True, TopLeft); unmanage(sel); } + if(dc.font.set) + XFreeFontSet(dpy, dc.font.set); + else + XFreeFont(dpy, dc.font.xfont); XUngrabKey(dpy, AnyKey, AnyModifier, root); + XFreePixmap(dpy, dc.drawable); + XFreeGC(dpy, dc.gc); + XDestroyWindow(dpy, barwin); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(dpy, False); } @@ -139,7 +147,7 @@ sendevent(Window w, Atom a, long value) void quit(Arg *arg) { - running = False; + readin = running = False; } /* @@ -169,7 +177,6 @@ main(int argc, char *argv[]) int i, j, xfd; unsigned int mask; fd_set rd; - Bool readin = True; Window w; XModifierKeymap *modmap; XSetWindowAttributes wa; @@ -272,17 +279,16 @@ main(int argc, char *argv[]) /* main event loop, also reads status text from stdin */ XSync(dpy, False); procevent(); + readin = True; while(running) { FD_ZERO(&rd); if(readin) FD_SET(STDIN_FILENO, &rd); FD_SET(xfd, &rd); i = select(xfd + 1, &rd, NULL, NULL, NULL); - if(i == -1 && errno == EINTR) + if((i == -1) && (errno == EINTR)) continue; - if(i < 0) - eprint("select failed\n"); - else if(i > 0) { + if(i > 0) { if(readin && FD_ISSET(STDIN_FILENO, &rd)) { readin = NULL != fgets(stext, sizeof(stext), stdin); if(readin) @@ -291,9 +297,10 @@ main(int argc, char *argv[]) strcpy(stext, "broken pipe"); drawstatus(); } - if(FD_ISSET(xfd, &rd)) - procevent(); } + else if(i < 0) + eprint("select failed\n"); + procevent(); } cleanup(); XCloseDisplay(dpy);