X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=main.c;h=6da3ccd57495ed2a2eef005fb205793dd9da28d7;hb=0ff80653d3c85715966de3c1fe76a8927ed8133d;hp=1bc4068b1eb06ad3a98492ba926b6143abb2fb7a;hpb=b43989207a949cbc17182b451aa527afe542c98f;p=dwm.git diff --git a/main.c b/main.c index 1bc4068..6da3ccd 100644 --- a/main.c +++ b/main.c @@ -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,19 @@ Window root, barwin; int getproto(Window w) { - int protos = 0; - int i; - long res; - Atom *protocols; - - res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, - ((unsigned char **)&protocols)); - if(res <= 0) { + int i, format, protos, status; + unsigned long extra, res; + Atom *protocols, real; + + protos = 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++) { + for(i = 0; i < res; i++) if(protocols[i] == wmatom[WMDelete]) protos |= PROTODELWIN; - } - free((char *) protocols); + free(protocols); return protos; } @@ -241,7 +220,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);