X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=main.c;h=6f60c9b07cf6f38811393115cdc8f72f1b11294b;hb=352e1b4c81d141cf60f98b38c93dd1fcd342c4a4;hp=50fb9d72dcf631e9c8c2c4394b16a95ecd3f008f;hpb=727449d1e7840bae1700d722168a73def9738ccd;p=dwm.git diff --git a/main.c b/main.c index 50fb9d7..6f60c9b 100644 --- a/main.c +++ b/main.c @@ -33,9 +33,9 @@ cleanup() else XFreeFont(dpy, dc.font.xfont); XUngrabKey(dpy, AnyKey, AnyModifier, root); - XDestroyWindow(dpy, barwin); XFreePixmap(dpy, dc.drawable); XFreeGC(dpy, dc.gc); + XDestroyWindow(dpy, barwin); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(dpy, False); } @@ -62,25 +62,6 @@ scan() XFree(wins); } -static int -win_property(Window w, Atom a, Atom t, long l, unsigned char **prop) -{ - int status, format; - unsigned long res, extra; - Atom real; - - status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format, - &res, &extra, prop); - - if(status != Success || *prop == 0) { - return 0; - } - if(res == 0) { - free((void *) *prop); - } - return res; -} - /* * Startup Error handler to check if another window manager * is already running. @@ -111,21 +92,20 @@ Window root, barwin; int getproto(Window w) { - int protos = 0; + int status, format, protos = 0; int i; - long res; - Atom *protocols; + unsigned long extra, res; + Atom *protocols, real; - res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, - ((unsigned char **)&protocols)); - if(res <= 0) { + status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, + False, XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols); + if(status != Success || protocols == 0) return protos; - } for(i = 0; i < res; i++) { if(protocols[i] == wmatom[WMDelete]) protos |= PROTODELWIN; } - free((char *) protocols); + free(protocols); return protos; } @@ -241,7 +221,7 @@ main(int argc, char *argv[]) for(ntags = 0; tags[ntags]; ntags++); seltag = emallocz(sizeof(Bool) * ntags); - seltag[DEFTAG] = True; + seltag[0] = True; /* style */ dc.bg = getcolor(BGCOLOR); @@ -286,11 +266,9 @@ main(int argc, char *argv[]) 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) @@ -300,6 +278,8 @@ main(int argc, char *argv[]) drawstatus(); } } + else if(i < 0) + eprint("select failed\n"); procevent(); } cleanup();