From 92e55c7c53cb808b584982ac8f6d69112d713fab Mon Sep 17 00:00:00 2001 From: "Anselm R.Garbe" Date: Tue, 8 Aug 2006 17:08:45 +0200 Subject: implemented NET_ACTIVE_WINDOW support --- client.c | 5 +++++ dwm.h | 2 +- event.c | 13 +++++++++++++ main.c | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client.c b/client.c index f92df83b..9b91ab65 100644 --- a/client.c +++ b/client.c @@ -58,6 +58,8 @@ focus(Client *c) drawtitle(c); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XSync(dpy, False); + XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32, + PropModeReplace, (unsigned char *)&c->win, 1); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } @@ -459,6 +461,9 @@ unmanage(Client *c) arrange(NULL); if(sel) focus(sel); + else + XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32, + PropModeReplace, (unsigned char *)NULL, 1); } void diff --git a/dwm.h b/dwm.h index 57d628ab..efef213d 100644 --- a/dwm.h +++ b/dwm.h @@ -22,7 +22,7 @@ union Arg { }; /* atoms */ -enum { NetSupported, NetWMName, NetLast }; +enum { NetSupported, NetWMName, NetActiveWindow, NetLast }; enum { WMProtocols, WMDelete, WMLast }; /* cursor */ diff --git a/event.c b/event.c index 2e4f62ee..c3169aa7 100644 --- a/event.c +++ b/event.c @@ -145,6 +145,18 @@ buttonpress(XEvent *e) } } +static void +clientmessage(XEvent *e) +{ + Client *c; + XClientMessageEvent *ev = &e->xclient; + + if(ev->message_type == netatom[NetActiveWindow]) { + if((c = getclient(ev->window)) && c->tags[tsel]) + focus(c); + } +} + static void configurerequest(XEvent *e) { @@ -339,6 +351,7 @@ unmapnotify(XEvent *e) void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, + [ClientMessage] = clientmessage, [ConfigureRequest] = configurerequest, [DestroyNotify] = destroynotify, [EnterNotify] = enternotify, diff --git a/main.c b/main.c index 5efe5997..ded47614 100644 --- a/main.c +++ b/main.c @@ -201,6 +201,7 @@ main(int argc, char *argv[]) wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); + netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast); -- cgit v1.2.3