From 728d2a40dd4e0151c6473179d35ca08fd0a0f1b4 Mon Sep 17 00:00:00 2001 From: oga Date: Mon, 7 Dec 2009 22:46:15 +0000 Subject: support _NET_CLIENT_LIST. the x property api doesn't let you remove one entry from an X property array, so client_remove is kinda expensive, but there's no real way around that.. ok okan@ --- calmwm.h | 3 ++- client.c | 23 +++++++++++++++++++++++ xutil.c | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/calmwm.h b/calmwm.h index 75f56ea..9885117 100644 --- a/calmwm.h +++ b/calmwm.h @@ -527,7 +527,8 @@ extern struct conf Conf; #define _NET_SUPPORTING_WM_CHECK cwm_atoms[8] #define _NET_WM_NAME cwm_atoms[9] #define _NET_ACTIVE_WINDOW cwm_atoms[10] -#define CWM_NO_ATOMS 11 +#define _NET_CLIENT_LIST cwm_atoms[11] +#define CWM_NO_ATOMS 12 #define CWM_NETWM_START 7 extern Atom cwm_atoms[CWM_NO_ATOMS]; diff --git a/client.c b/client.c index fed35de..1d4118b 100644 --- a/client.c +++ b/client.c @@ -114,6 +114,9 @@ client_new(Window win, struct screen_ctx *sc, int mapped) TAILQ_INSERT_TAIL(&sc->mruq, cc, mru_entry); TAILQ_INSERT_TAIL(&Clientq, cc, entry); + /* append to the client list */ + XChangeProperty(X_Dpy, sc->rootwin, _NET_CLIENT_LIST, XA_WINDOW, 32, + PropModeAppend, (unsigned char *)&cc->win, 1); client_gethints(cc); client_update(cc); @@ -128,7 +131,10 @@ int client_delete(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; + struct client_ctx *tcc; struct winname *wn; + Window *winlist; + int i, j; group_client_delete(cc); @@ -141,6 +147,23 @@ client_delete(struct client_ctx *cc) TAILQ_REMOVE(&sc->mruq, cc, mru_entry); TAILQ_REMOVE(&Clientq, cc, entry); + /* + * Sadly we can't remove just one entry from a property, so we must + * redo the whole thing from scratch. this is the stupid way, the other + * way incurs many roundtrips to the server. + */ + i = j = 0; + TAILQ_FOREACH(tcc, &Clientq, entry) + i++; + if (i > 0) { + winlist = xmalloc(i * sizeof(*winlist)); + TAILQ_FOREACH(tcc, &Clientq, entry) + winlist[j++] = tcc->win; + XChangeProperty(X_Dpy, sc->rootwin, _NET_CLIENT_LIST, + XA_WINDOW, 32, PropModeReplace, + (unsigned char *)winlist, i); + xfree(winlist); + } if (_curcc == cc) client_none(sc); diff --git a/xutil.c b/xutil.c index d4e4f62..6b191ff 100644 --- a/xutil.c +++ b/xutil.c @@ -182,6 +182,7 @@ char *atoms[CWM_NO_ATOMS] = { "_NET_SUPPORTING_WM_CHECK", "_NET_WM_NAME", "_NET_ACTIVE_WINDOW", + "_NET_CLIENT_LIST", }; void -- cgit 1.4.1