On Sun, Mar 25, 2012 at 04:33:23PM +0300, Ivan Kanakarakis wrote:
> A quick look into the tip of dwm, shows that it is the case for dwm.
> It doesn't set the _NET_ACTIVE_WINDOW property correctly,
> although the atom is there, and included in _NET_SUPPORTED.
> 
> To fix that, one must call (supposing c is
> the Client that holds the current window) :
> 
> XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW,
> 32, PropModeReplace, (unsigned char*)&c->window, 1);
> 
> everytime the current window changes.
> also one should delete the property if there is no active window
> (either no window on the screen, or no window focused)

Attached is a patch which does that.  It works for me. 

If you want support for NetActiveWindow, you probably also want support
for NetClientList.  The second patch implements that.

Andreas

# HG changeset patch
# Parent bbfe55c2f7562ea3e428d4c7cbd1d8da0c32f02f

diff --git a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -499,6 +500,7 @@
                cleanupmon(mons);
        XSync(dpy, False);
        XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
+       XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
 }
 
 void
@@ -858,8 +860,10 @@
                XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
                setfocus(c);
        }
-       else
+       else {
                XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+               XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
+       }
        selmon->sel = c;
        drawbars();
 }
@@ -1520,8 +1526,12 @@
 
 void
 setfocus(Client *c) {
-       if(!c->neverfocus)
+       if(!c->neverfocus) {
                XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+               XChangeProperty(dpy, root, netatom[NetActiveWindow],
+                               XA_WINDOW, 32, PropModeReplace,
+                               (unsigned char *) &(c->win), 1);
+       }
        sendevent(c, wmatom[WMTakeFocus]);
 }
 
@@ -1777,8 +1789,10 @@
                return;
        grabbuttons(c, False);
        XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
-       if(setfocus)
+       if(setfocus) {
                XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+               XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
+       }
 }
 
 void
# HG changeset patch
# Parent bbfe55c2f7562ea3e428d4c7cbd1d8da0c32f02f

diff --git a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -60,7 +60,7 @@
 enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
 enum { NetSupported, NetWMName, NetWMState,
        NetWMFullscreen, NetActiveWindow, NetWMWindowType,
-       NetWMWindowTypeDialog, NetLast };     /* EWMH atoms */
+       NetWMWindowTypeDialog, NetClientList, NetLast };     /* EWMH atoms */
 enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms 
*/
 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
        ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
@@ -238,6 +238,7 @@
 static Bool updategeom(void);
 static void updatebarpos(Monitor *m);
 static void updatebars(void);
+static void updateclientlist(void);
 static void updatenumlockmask(void);
 static void updatesizehints(Client *c);
 static void updatestatus(void);
@@ -1157,6 +1161,8 @@
                XRaiseWindow(dpy, c->win);
        attach(c);
        attachstack(c);
+       XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, 
PropModeAppend,
+                       (unsigned char *) &(c->win), 1);
        XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* 
some windows require this */
        setclientstate(c, NormalState);
        if (c->mon == selmon)
@@ -1607,6 +1617,7 @@
        netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", 
False);
        netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", 
False);
        netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, 
"_NET_WM_WINDOW_TYPE_DIALOG", False);
+       netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
        /* init cursors */
        cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
        cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
@@ -1629,6 +1640,7 @@
        /* EWMH support per view */
        XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
                        PropModeReplace, (unsigned char *) netatom, NetLast);
+       XDeleteProperty(dpy, root, netatom[NetClientList]);
        /* select for events */
        wa.cursor = cursor[CurNormal];
        wa.event_mask = 
SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask
@@ -1802,6 +1816,7 @@
        }
        free(c);
        focus(NULL);
+       updateclientlist();
        arrange(m);
 }
 
@@ -1848,6 +1863,19 @@
                m->by = -bh;
 }
 
+void
+updateclientlist() {
+       Client *c;
+       Monitor *m;
+
+       XDeleteProperty(dpy, root, netatom[NetClientList]);
+       for(m = mons; m; m = m->next)
+               for(c = m->clients; c; c = c->next)
+                       XChangeProperty(dpy, root, netatom[NetClientList],
+                                       XA_WINDOW, 32, PropModeAppend,
+                                       (unsigned char *) &(c->win), 1);
+}
+
 Bool
 updategeom(void) {
        Bool dirty = False;

Reply via email to