[hackers] dwm: new tip (= 735)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Wed, 07 Feb 2007 12:40:02 +0100

changeset: 735:9ede7b2d2450
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Wed Feb 07 12:37:21 2007 +0100
files: config.mk
description:
removed debug flags

changeset: 734:6283adb1fcf2
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Wed Feb 07 12:37:06 2007 +0100
files: client.c config.mk dwm.h event.c main.c
description:
replaced getproto with a saner function, now old-school artifacts of WM times in the early 90s completely disappeared, no punned pointer warning anymore ;)

diff -r 1950833a5614 -r 9ede7b2d2450 client.c
--- a/client.c Tue Feb 06 15:29:19 2007 +0100
+++ b/client.c Wed Feb 07 12:37:21 2007 +0100
@@ -120,11 +120,26 @@ getclient(Window w) {
         return NULL;
 }
 
+Bool
+isprotodel(Client *c) {
+ int i, n;
+ Atom *protocols;
+ Bool ret = False;
+
+ if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
+ for(i = 0; !ret && i < n; i++)
+ if(protocols[i] == wmatom[WMDelete])
+ ret = True;
+ XFree(protocols);
+ }
+ return ret;
+}
+
 void
 killclient(Arg *arg) {
         if(!sel)
                 return;
- if(sel->proto & PROTODELWIN)
+ if(isprotodel(sel))
                 sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
         else
                 XKillClient(dpy, sel->win);
@@ -159,7 +174,6 @@ manage(Window w, XWindowAttributes *wa)
                         c->y = way;
         }
         updatesizehints(c);
- c->proto = getproto(c->win);
         XSelectInput(dpy, c->win,
                 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
         XGetTransientForHint(dpy, c->win, &trans);
diff -r 1950833a5614 -r 9ede7b2d2450 dwm.h
--- a/dwm.h Tue Feb 06 15:29:19 2007 +0100
+++ b/dwm.h Wed Feb 07 12:37:21 2007 +0100
@@ -36,8 +36,6 @@
 
 /* mask shorthands, used in event.c and client.c */
 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
-/* other stuff used in different places */
-#define PROTODELWIN 1
 
 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
 enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
@@ -69,14 +67,13 @@ typedef struct Client Client;
 typedef struct Client Client;
 struct Client {
         char name[256];
- int proto;
         int x, y, w, h;
         int rx, ry, rw, rh; /* revert geometry */
         int basew, baseh, incw, inch, maxw, maxh, minw, minh;
         int minax, minay, maxax, maxay;
         long flags;
         unsigned int border;
- Bool isfloat, isfixed, ismax;
+ Bool isfixed, isfloat, ismax;
         Bool *tags;
         Client *next;
         Client *prev;
@@ -105,6 +102,7 @@ extern void configure(Client *c); /* se
 extern void configure(Client *c); /* send synthetic configure event */
 extern void focus(Client *c); /* focus c, c may be NULL */
 extern Client *getclient(Window w); /* return client of w */
+extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
 extern void killclient(Arg *arg); /* kill c nicely */
 extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
 extern void resize(Client *c, Bool sizehints); /* resize c*/
@@ -123,7 +121,6 @@ extern void procevent(void); /* proces
 extern void procevent(void); /* process pending X events */
 
 /* main.c */
-extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */
 extern void quit(Arg *arg); /* quit dwm nicely */
 extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
 extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
diff -r 1950833a5614 -r 9ede7b2d2450 event.c
--- a/event.c Tue Feb 06 15:29:19 2007 +0100
+++ b/event.c Wed Feb 07 12:37:21 2007 +0100
@@ -308,10 +308,6 @@ propertynotify(XEvent *e) {
         if(ev->state == PropertyDelete)
                 return; /* ignore */
         if((c = getclient(ev->window))) {
- if(ev->atom == wmatom[WMProtocols]) {
- c->proto = getproto(c->win);
- return;
- }
                 switch (ev->atom) {
                         default: break;
                         case XA_WM_TRANSIENT_FOR:
diff -r 1950833a5614 -r 9ede7b2d2450 main.c
--- a/main.c Tue Feb 06 15:29:19 2007 +0100
+++ b/main.c Wed Feb 07 12:37:21 2007 +0100
@@ -172,24 +172,6 @@ xerrorstart(Display *dsply, XErrorEvent
 
 /* extern */
 
-int
-getproto(Window w) {
- 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++)
- if(protocols[i] == wmatom[WMDelete])
- protos |= PROTODELWIN;
- free(protocols);
- return protos;
-}
-
 void
 sendevent(Window w, Atom a, long value) {
         XEvent e;
Received on Wed Feb 07 2007 - 12:40:02 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:57 UTC