diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-02-07 12:37:06 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-02-07 12:37:06 +0100 |
| commit | 28ffff801bb0137ec3fe4093afc4fb29784b17ec (patch) | |
| tree | 2072e2465fb0b3cbf4f3241a096de99752e79be1 | |
| parent | yet another fix (diff) | |
| download | dwm-28ffff801bb0137ec3fe4093afc4fb29784b17ec.tar.gz dwm-28ffff801bb0137ec3fe4093afc4fb29784b17ec.zip | |
replaced getproto with a saner function, now old-school artifacts of WM times in the early 90s completely disappeared, no punned pointer warning anymore ;)
| -rw-r--r-- | client.c | 18 | ||||
| -rw-r--r-- | config.mk | 4 | ||||
| -rw-r--r-- | dwm.h | 7 | ||||
| -rw-r--r-- | event.c | 4 | ||||
| -rw-r--r-- | main.c | 18 |
5 files changed, 20 insertions, 31 deletions
| @@ -120,11 +120,26 @@ getclient(Window w) { | |||
| 120 | return NULL; | 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 | void | 138 | void |
| 124 | killclient(Arg *arg) { | 139 | killclient(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); |
| @@ -17,8 +17,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 | |||
| 17 | # flags | 17 | # flags |
| 18 | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" | 18 | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" |
| 19 | LDFLAGS = ${LIBS} | 19 | LDFLAGS = ${LIBS} |
| 20 | #CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" | 20 | CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" |
| 21 | #LDFLAGS = -g ${LIBS} | 21 | LDFLAGS = -g ${LIBS} |
| 22 | 22 | ||
| 23 | # Solaris | 23 | # Solaris |
| 24 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" | 24 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" |
| @@ -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 | ||
| 42 | enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ | 40 | enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ |
| 43 | enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ | 41 | enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ |
| @@ -69,14 +67,13 @@ typedef struct { | |||
| 69 | typedef struct Client Client; | 67 | typedef struct Client Client; |
| 70 | struct Client { | 68 | struct 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; | |||
| 105 | extern void configure(Client *c); /* send synthetic configure event */ | 102 | extern void configure(Client *c); /* send synthetic configure event */ |
| 106 | extern void focus(Client *c); /* focus c, c may be NULL */ | 103 | extern void focus(Client *c); /* focus c, c may be NULL */ |
| 107 | extern Client *getclient(Window w); /* return client of w */ | 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 | extern void killclient(Arg *arg); /* kill c nicely */ | 106 | extern void killclient(Arg *arg); /* kill c nicely */ |
| 109 | extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ | 107 | extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ |
| 110 | extern void resize(Client *c, Bool sizehints); /* resize c*/ | 108 | extern void resize(Client *c, Bool sizehints); /* resize c*/ |
| @@ -123,7 +121,6 @@ extern void grabkeys(void); /* grab all keys defined in config.h */ | |||
| 123 | extern void procevent(void); /* process pending X events */ | 121 | extern void procevent(void); /* process pending X events */ |
| 124 | 122 | ||
| 125 | /* main.c */ | 123 | /* main.c */ |
| 126 | extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */ | ||
| 127 | extern void quit(Arg *arg); /* quit dwm nicely */ | 124 | extern void quit(Arg *arg); /* quit dwm nicely */ |
| 128 | extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ | 125 | extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ |
| 129 | extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ | 126 | extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ |
| @@ -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: |
| @@ -172,24 +172,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) { | |||
| 172 | 172 | ||
| 173 | /* extern */ | 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 | void | 175 | void |
| 194 | sendevent(Window w, Atom a, long value) { | 176 | sendevent(Window w, Atom a, long value) { |
| 195 | XEvent e; | 177 | XEvent e; |
