[dev] Re: [dwm] NetActiveWindow

From: Peter John Hartman <peterjohnhartman_AT_gmail.com>
Date: Wed, 13 Apr 2011 15:58:33 -0400

On Tue, Apr 12, 2011 at 11:08:20AM -0400, Peter John Hartman wrote:
> Hi. Thanks go also to LokiChaos on #suckless. With this little patch[1] you
> can now use this little script[2] (and others presumably) to manipulate windows
> via xdotool in dwm.

As it turns out [1] was rather incomplete. If you ran

$ xdotool windowactivate 123

and the window associated with id 123 happened to be on some
tag other than the tag that you happened to be on, guess what?
Nothing happened. Hence, this version has dwm hop on over to
the appropriate tag.

I would submit, at the very least, that the top and bottom bit of this patch
get incorporated into dwm, for then xlsclients works whereas before it would
bail with a complaint (something like: I refuse to even list information if
your window manager doesn't recognize _NET_ACTIVE_WINDOW). The middle bit
of the patch allows "xdotool windowactive 123" to actually *activate a
window*; but maybe not everyone really cares about that.

Here's the new patch:

diff -r 072c62ed10f2 dwm.c
--- a/dwm.c Fri Jan 07 16:05:22 2011 +0000
+++ b/dwm.c Wed Apr 13 08:16:35 2011 -0400
@@ -58,7 +58,7 @@
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
 enum { NetSupported, NetWMName, NetWMState,
- NetWMFullscreen, NetLast }; /* EWMH atoms */
+ NetWMFullscreen, NetActiveWindow, NetLast }; /* EWMH atoms */
 enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
        ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
@@ -1310,6 +1310,16 @@
                         arrange(c->mon);
                 }
         }
+ if((c = wintoclient(cme->window))
+ && (cme->message_type == netatom[NetActiveWindow] && cme->data.l[0]))
+ {
+ int t;
+ for(t = 0; !((1<<t)&c->tags); t++);
+ Arg a = {.i = (1 << t) };
+ view(&a);
+ focus(c);
+ restack(selmon);
+ }
 }
 
 void
@@ -1517,6 +1527,7 @@
         wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
         wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
         wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
+ netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
         netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
         netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
         netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);

-- 
sic dicit magister P
PhD Candidate
Collaborative Programme in Ancient and Medieval Philosophy
University of Toronto
http://individual.utoronto.ca/peterjh
Received on Wed Apr 13 2011 - 21:58:33 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 13 2011 - 22:00:05 CEST