dwm-meillo
changeset 734:6283adb1fcf2
replaced getproto with a saner function, now old-school artifacts of WM times in the early 90s completely disappeared, no punned pointer warning anymore ;)
author | Anselm R. Garbe <arg@suckless.org> |
---|---|
date | Wed, 07 Feb 2007 12:37:06 +0100 |
parents | 1950833a5614 |
children | 9ede7b2d2450 |
files | client.c config.mk dwm.h event.c main.c |
diffstat | 5 files changed, 20 insertions(+), 31 deletions(-) [+] |
line diff
1.1 --- a/client.c Tue Feb 06 15:29:19 2007 +0100 1.2 +++ b/client.c Wed Feb 07 12:37:06 2007 +0100 1.3 @@ -120,11 +120,26 @@ 1.4 return NULL; 1.5 } 1.6 1.7 +Bool 1.8 +isprotodel(Client *c) { 1.9 + int i, n; 1.10 + Atom *protocols; 1.11 + Bool ret = False; 1.12 + 1.13 + if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { 1.14 + for(i = 0; !ret && i < n; i++) 1.15 + if(protocols[i] == wmatom[WMDelete]) 1.16 + ret = True; 1.17 + XFree(protocols); 1.18 + } 1.19 + return ret; 1.20 +} 1.21 + 1.22 void 1.23 killclient(Arg *arg) { 1.24 if(!sel) 1.25 return; 1.26 - if(sel->proto & PROTODELWIN) 1.27 + if(isprotodel(sel)) 1.28 sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]); 1.29 else 1.30 XKillClient(dpy, sel->win); 1.31 @@ -159,7 +174,6 @@ 1.32 c->y = way; 1.33 } 1.34 updatesizehints(c); 1.35 - c->proto = getproto(c->win); 1.36 XSelectInput(dpy, c->win, 1.37 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 1.38 XGetTransientForHint(dpy, c->win, &trans);
2.1 --- a/config.mk Tue Feb 06 15:29:19 2007 +0100 2.2 +++ b/config.mk Wed Feb 07 12:37:06 2007 +0100 2.3 @@ -17,8 +17,8 @@ 2.4 # flags 2.5 CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" 2.6 LDFLAGS = ${LIBS} 2.7 -#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" 2.8 -#LDFLAGS = -g ${LIBS} 2.9 +CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" 2.10 +LDFLAGS = -g ${LIBS} 2.11 2.12 # Solaris 2.13 #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
3.1 --- a/dwm.h Tue Feb 06 15:29:19 2007 +0100 3.2 +++ b/dwm.h Wed Feb 07 12:37:06 2007 +0100 3.3 @@ -36,8 +36,6 @@ 3.4 3.5 /* mask shorthands, used in event.c and client.c */ 3.6 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) 3.7 -/* other stuff used in different places */ 3.8 -#define PROTODELWIN 1 3.9 3.10 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ 3.11 enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ 3.12 @@ -69,14 +67,13 @@ 3.13 typedef struct Client Client; 3.14 struct Client { 3.15 char name[256]; 3.16 - int proto; 3.17 int x, y, w, h; 3.18 int rx, ry, rw, rh; /* revert geometry */ 3.19 int basew, baseh, incw, inch, maxw, maxh, minw, minh; 3.20 int minax, minay, maxax, maxay; 3.21 long flags; 3.22 unsigned int border; 3.23 - Bool isfloat, isfixed, ismax; 3.24 + Bool isfixed, isfloat, ismax; 3.25 Bool *tags; 3.26 Client *next; 3.27 Client *prev; 3.28 @@ -105,6 +102,7 @@ 3.29 extern void configure(Client *c); /* send synthetic configure event */ 3.30 extern void focus(Client *c); /* focus c, c may be NULL */ 3.31 extern Client *getclient(Window w); /* return client of w */ 3.32 +extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */ 3.33 extern void killclient(Arg *arg); /* kill c nicely */ 3.34 extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ 3.35 extern void resize(Client *c, Bool sizehints); /* resize c*/ 3.36 @@ -123,7 +121,6 @@ 3.37 extern void procevent(void); /* process pending X events */ 3.38 3.39 /* main.c */ 3.40 -extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */ 3.41 extern void quit(Arg *arg); /* quit dwm nicely */ 3.42 extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ 3.43 extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
4.1 --- a/event.c Tue Feb 06 15:29:19 2007 +0100 4.2 +++ b/event.c Wed Feb 07 12:37:06 2007 +0100 4.3 @@ -308,10 +308,6 @@ 4.4 if(ev->state == PropertyDelete) 4.5 return; /* ignore */ 4.6 if((c = getclient(ev->window))) { 4.7 - if(ev->atom == wmatom[WMProtocols]) { 4.8 - c->proto = getproto(c->win); 4.9 - return; 4.10 - } 4.11 switch (ev->atom) { 4.12 default: break; 4.13 case XA_WM_TRANSIENT_FOR:
5.1 --- a/main.c Tue Feb 06 15:29:19 2007 +0100 5.2 +++ b/main.c Wed Feb 07 12:37:06 2007 +0100 5.3 @@ -172,24 +172,6 @@ 5.4 5.5 /* extern */ 5.6 5.7 -int 5.8 -getproto(Window w) { 5.9 - int i, format, protos, status; 5.10 - unsigned long extra, res; 5.11 - Atom *protocols, real; 5.12 - 5.13 - protos = 0; 5.14 - status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False, 5.15 - XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols); 5.16 - if(status != Success || protocols == 0) 5.17 - return protos; 5.18 - for(i = 0; i < res; i++) 5.19 - if(protocols[i] == wmatom[WMDelete]) 5.20 - protos |= PROTODELWIN; 5.21 - free(protocols); 5.22 - return protos; 5.23 -} 5.24 - 5.25 void 5.26 sendevent(Window w, Atom a, long value) { 5.27 XEvent e;