aboutsummaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authoroga2009-12-07 22:46:15 +0000
committeroga2009-12-07 22:46:15 +0000
commitff7157bb69ba801513b0ee6af1db2cde51ac62aa (patch)
treedaccfa006fd38fcac565a0b4bebc89fffe828c71 /client.c
parentad1677271ac08bca24c9d41bcbe555353687eb58 (diff)
downloadcwm-ff7157bb69ba801513b0ee6af1db2cde51ac62aa.tar.gz
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@
Diffstat (limited to '')
-rw-r--r--client.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/client.c b/client.c
index 16f5fd5..a8eaf06 100644
--- a/client.c
+++ b/client.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: client.c,v 1.67 2009/12/07 22:21:59 oga Exp $
+ * $Id: client.c,v 1.68 2009/12/07 22:46:15 oga Exp $
*/
#include "headers.h"
@@ -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);