summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c18
-rw-r--r--config.mk4
-rw-r--r--dwm.h7
-rw-r--r--event.c4
-rw-r--r--main.c18
5 files changed, 20 insertions, 31 deletions
diff --git a/client.c b/client.c
index 50e8a94..e37b9e6 100644
--- a/client.c
+++ b/client.c
@@ -120,11 +120,26 @@ getclient(Window w) {
120 return NULL; 120 return NULL;
121} 121}
122 122
123Bool
124isprotodel(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
123void 138void
124killclient(Arg *arg) { 139killclient(Arg *arg) {
125 if(!sel) 140 if(!sel)
126 return; 141 return;
127 if(sel->proto & PROTODELWIN) 142 if(isprotodel(sel))
128 sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]); 143 sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
129 else 144 else
130 XKillClient(dpy, sel->win); 145 XKillClient(dpy, sel->win);
@@ -159,7 +174,6 @@ manage(Window w, XWindowAttributes *wa) {
159 c->y = way; 174 c->y = way;
160 } 175 }
161 updatesizehints(c); 176 updatesizehints(c);
162 c->proto = getproto(c->win);
163 XSelectInput(dpy, c->win, 177 XSelectInput(dpy, c->win,
164 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 178 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
165 XGetTransientForHint(dpy, c->win, &trans); 179 XGetTransientForHint(dpy, c->win, &trans);
diff --git a/config.mk b/config.mk
index 338632d..2e5630a 100644
--- a/config.mk
+++ b/config.mk
@@ -17,8 +17,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
17# flags 17# flags
18CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" 18CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
19LDFLAGS = ${LIBS} 19LDFLAGS = ${LIBS}
20#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" 20CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
21#LDFLAGS = -g ${LIBS} 21LDFLAGS = -g ${LIBS}
22 22
23# Solaris 23# Solaris
24#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" 24#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
diff --git a/dwm.h b/dwm.h
index a7053c5..674ab1e 100644
--- a/dwm.h
+++ b/dwm.h
@@ -36,8 +36,6 @@
36 36
37/* mask shorthands, used in event.c and client.c */ 37/* mask shorthands, used in event.c and client.c */
38#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) 38#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
39/* other stuff used in different places */
40#define PROTODELWIN 1
41 39
42enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ 40enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
43enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ 41enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
@@ -69,14 +67,13 @@ typedef struct {
69typedef struct Client Client; 67typedef struct Client Client;
70struct Client { 68struct Client {
71 char name[256]; 69 char name[256];
72 int proto;
73 int x, y, w, h; 70 int x, y, w, h;
74 int rx, ry, rw, rh; /* revert geometry */ 71 int rx, ry, rw, rh; /* revert geometry */
75 int basew, baseh, incw, inch, maxw, maxh, minw, minh; 72 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
76 int minax, minay, maxax, maxay; 73 int minax, minay, maxax, maxay;
77 long flags; 74 long flags;
78 unsigned int border; 75 unsigned int border;
79 Bool isfloat, isfixed, ismax; 76 Bool isfixed, isfloat, ismax;
80 Bool *tags; 77 Bool *tags;
81 Client *next; 78 Client *next;
82 Client *prev; 79 Client *prev;
@@ -105,6 +102,7 @@ extern Window root, barwin;
105extern void configure(Client *c); /* send synthetic configure event */ 102extern void configure(Client *c); /* send synthetic configure event */
106extern void focus(Client *c); /* focus c, c may be NULL */ 103extern void focus(Client *c); /* focus c, c may be NULL */
107extern Client *getclient(Window w); /* return client of w */ 104extern Client *getclient(Window w); /* return client of w */
105extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
108extern void killclient(Arg *arg); /* kill c nicely */ 106extern void killclient(Arg *arg); /* kill c nicely */
109extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ 107extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
110extern void resize(Client *c, Bool sizehints); /* resize c*/ 108extern void resize(Client *c, Bool sizehints); /* resize c*/
@@ -123,7 +121,6 @@ extern void grabkeys(void); /* grab all keys defined in config.h */
123extern void procevent(void); /* process pending X events */ 121extern void procevent(void); /* process pending X events */
124 122
125/* main.c */ 123/* main.c */
126extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */
127extern void quit(Arg *arg); /* quit dwm nicely */ 124extern void quit(Arg *arg); /* quit dwm nicely */
128extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ 125extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
129extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ 126extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
diff --git a/event.c b/event.c
index 418e986..c66aa72 100644
--- a/event.c
+++ b/event.c
@@ -308,10 +308,6 @@ propertynotify(XEvent *e) {
308 if(ev->state == PropertyDelete) 308 if(ev->state == PropertyDelete)
309 return; /* ignore */ 309 return; /* ignore */
310 if((c = getclient(ev->window))) { 310 if((c = getclient(ev->window))) {
311 if(ev->atom == wmatom[WMProtocols]) {
312 c->proto = getproto(c->win);
313 return;
314 }
315 switch (ev->atom) { 311 switch (ev->atom) {
316 default: break; 312 default: break;
317 case XA_WM_TRANSIENT_FOR: 313 case XA_WM_TRANSIENT_FOR:
diff --git a/main.c b/main.c
index 97fdbaf..da95d95 100644
--- a/main.c
+++ b/main.c
@@ -172,24 +172,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
172 172
173/* extern */ 173/* extern */
174 174
175int
176getproto(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
193void 175void
194sendevent(Window w, Atom a, long value) { 176sendevent(Window w, Atom a, long value) {
195 XEvent e; 177 XEvent e;