replaced getproto with a saner function, now old-school artifacts of WM times in the early 90s completely disappeared, no punned pointer warning anymore ;) 28ffff80
Anselm R. Garbe · 2007-02-07 12:37 5 file(s) · +20 −31
client.c +16 −2
120 120
	return NULL;
121 121
}
122 122
123 +
Bool
124 +
isprotodel(Client *c) {
125 +
	int i, n;
126 +
	Atom *protocols;
127 +
	Bool ret = False;
128 +
129 +
	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
130 +
		for(i = 0; !ret && i < n; i++)
131 +
			if(protocols[i] == wmatom[WMDelete])
132 +
				ret = True;
133 +
		XFree(protocols);
134 +
	}
135 +
	return ret;
136 +
}
137 +
123 138
void
124 139
killclient(Arg *arg) {
125 140
	if(!sel)
126 141
		return;
127 -
	if(sel->proto & PROTODELWIN)
142 +
	if(isprotodel(sel))
128 143
		sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
129 144
	else
130 145
		XKillClient(dpy, sel->win);
159 174
			c->y = way;
160 175
	}
161 176
	updatesizehints(c);
162 -
	c->proto = getproto(c->win);
163 177
	XSelectInput(dpy, c->win,
164 178
		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
165 179
	XGetTransientForHint(dpy, c->win, &trans);
config.mk +2 −2
17 17
# flags
18 18
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
19 19
LDFLAGS = ${LIBS}
20 -
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
21 -
#LDFLAGS = -g ${LIBS}
20 +
CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
21 +
LDFLAGS = -g ${LIBS}
22 22
23 23
# Solaris
24 24
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
dwm.h +2 −5
36 36
37 37
/* mask shorthands, used in event.c and client.c */
38 38
#define BUTTONMASK		(ButtonPressMask | ButtonReleaseMask)
39 -
/* other stuff used in different places */
40 -
#define PROTODELWIN		1
41 39
42 40
enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
43 41
enum { WMProtocols, WMDelete, WMState, WMLast };	/* default atoms */
69 67
typedef struct Client Client;
70 68
struct Client {
71 69
	char name[256];
72 -
	int proto;
73 70
	int x, y, w, h;
74 71
	int rx, ry, rw, rh; /* revert geometry */
75 72
	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
76 73
	int minax, minay, maxax, maxay;
77 74
	long flags; 
78 75
	unsigned int border;
79 -
	Bool isfloat, isfixed, ismax;
76 +
	Bool isfixed, isfloat, ismax;
80 77
	Bool *tags;
81 78
	Client *next;
82 79
	Client *prev;
105 102
extern void configure(Client *c);		/* send synthetic configure event */
106 103
extern void focus(Client *c);			/* focus c, c may be NULL */
107 104
extern Client *getclient(Window w);		/* return client of w */
105 +
extern Bool isprotodel(Client *c);		/* returns True if c->win supports wmatom[WMDelete] */
108 106
extern void killclient(Arg *arg);		/* kill c nicely */
109 107
extern void manage(Window w, XWindowAttributes *wa);	/* manage new client */
110 108
extern void resize(Client *c, Bool sizehints);	/* resize c*/
123 121
extern void procevent(void);			/* process pending X events */
124 122
125 123
/* main.c */
126 -
extern int getproto(Window w);			/* return protocol mask of WMProtocols property of w */
127 124
extern void quit(Arg *arg);			/* quit dwm nicely */
128 125
extern void sendevent(Window w, Atom a, long value);	/* send synthetic event to w */
129 126
extern int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
event.c +0 −4
308 308
	if(ev->state == PropertyDelete)
309 309
		return; /* ignore */
310 310
	if((c = getclient(ev->window))) {
311 -
		if(ev->atom == wmatom[WMProtocols]) {
312 -
			c->proto = getproto(c->win);
313 -
			return;
314 -
		}
315 311
		switch (ev->atom) {
316 312
			default: break;
317 313
			case XA_WM_TRANSIENT_FOR:
main.c +0 −18
172 172
173 173
/* extern */
174 174
175 -
int
176 -
getproto(Window w) {
177 -
	int i, format, protos, status;
178 -
	unsigned long extra, res;
179 -
	Atom *protocols, real;
180 -
181 -
	protos = 0;
182 -
	status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False,
183 -
			XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols);
184 -
	if(status != Success || protocols == 0)
185 -
		return protos;
186 -
	for(i = 0; i < res; i++)
187 -
		if(protocols[i] == wmatom[WMDelete])
188 -
			protos |= PROTODELWIN;
189 -
	free(protocols);
190 -
	return protos;
191 -
}
192 -
193 175
void
194 176
sendevent(Window w, Atom a, long value) {
195 177
	XEvent e;