summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2014-02-07 18:09:54 +0000
committerokan <okan>2014-02-07 18:09:54 +0000
commit3cb81ebeead55a21f679f54e1a4105dccb2a613c (patch)
tree6da231ddfe2520b2f6c3fe8afc1772c224208b37
parent98d8483d358747ad006cb37a9f29fc96e10a8827 (diff)
downloadcwm-3cb81ebeead55a21f679f54e1a4105dccb2a613c.tar.gz
cwm-3cb81ebeead55a21f679f54e1a4105dccb2a613c.tar.xz
cwm-3cb81ebeead55a21f679f54e1a4105dccb2a613c.zip
If _NET_WM_DESKTOP is set to -1 during client creation, place the client into
group 0 (nogroup); solves problem initially discovered by oga@nicotinebsd with
tint2.  A clientmessage *after* client creation already handles this case.

Go further and assign every client to a group; in non-sticky mode, group 0
(nogroup) and sticky mode, the active group.  In both cases, autogroup will
override the group assignment.  Removing a group from a client always places
the client back into group 0 (nogroup).  Autogroup can also assign a client to
group 0 (nogroup) to keep a client always visible (unless of course one opts to
hide all clients).
-rw-r--r--group.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/group.c b/group.c
index 70bd8b6..e993b91 100644
--- a/group.c
+++ b/group.c
@@ -32,8 +32,7 @@
 
 #include "calmwm.h"
 
-static void		 group_add(struct group_ctx *, struct client_ctx *);
-static void		 group_remove(struct client_ctx *);
+static void		 group_assign(struct group_ctx *, struct client_ctx *);
 static void		 group_hide(struct screen_ctx *, struct group_ctx *);
 static void		 group_show(struct screen_ctx *, struct group_ctx *);
 static void		 group_fix_hidden_state(struct group_ctx *);
@@ -46,11 +45,10 @@ const char *shortcut_to_name[] = {
 };
 
 static void
-group_add(struct group_ctx *gc, struct client_ctx *cc)
+group_assign(struct group_ctx *gc, struct client_ctx *cc)
 {
-	if (cc == NULL || gc == NULL)
-		errx(1, "group_add: a ctx is NULL");
-
+	if (gc == NULL)
+		gc = TAILQ_FIRST(&cc->sc->groupq);
 	if (cc->group == gc)
 		return;
 
@@ -64,18 +62,6 @@ group_add(struct group_ctx *gc, struct client_ctx *cc)
 }
 
 static void
-group_remove(struct client_ctx *cc)
-{
-	if (cc == NULL || cc->group == NULL)
-		errx(1, "group_remove: a ctx is NULL");
-
-	TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
-	cc->group = NULL;
-
-	xu_ewmh_net_wm_desktop(cc);
-}
-
-static void
 group_hide(struct screen_ctx *sc, struct group_ctx *gc)
 {
 	struct client_ctx	*cc;
@@ -186,7 +172,7 @@ group_movetogroup(struct client_ctx *cc, int idx)
 		client_hide(cc);
 		gc->nhidden++;
 	}
-	group_add(gc, cc);
+	group_assign(gc, cc);
 }
 
 /*
@@ -199,10 +185,10 @@ group_sticky_toggle_enter(struct client_ctx *cc)
 	struct group_ctx	*gc = sc->group_active;
 
 	if (gc == cc->group) {
-		group_remove(cc);
+		group_assign(NULL, cc);
 		cc->flags |= CLIENT_UNGROUP;
 	} else {
-		group_add(gc, cc);
+		group_assign(gc, cc);
 		cc->flags |= CLIENT_GROUP;
 	}
 
@@ -369,7 +355,7 @@ group_autogroup(struct client_ctx *cc)
 
 	if (xu_getprop(cc->win, ewmh[_NET_WM_DESKTOP],
 	    XA_CARDINAL, 1, (unsigned char **)&grpno) > 0) {
-		if (*grpno == 0xffffffff)
+		if (*grpno == -1)
 			no = 0;
 		else if (*grpno > CALMWM_NGROUPS || *grpno < 0)
 			no = CALMWM_NGROUPS - 1;
@@ -389,19 +375,17 @@ group_autogroup(struct client_ctx *cc)
 		}
 	}
 
-	/* no group please */
-	if (no == 0)
-		return;
-
 	TAILQ_FOREACH(gc, &sc->groupq, entry) {
 		if (gc->shortcut == no) {
-			group_add(gc, cc);
+			group_assign(gc, cc);
 			return;
 		}
 	}
 
 	if (Conf.flags & CONF_STICKY_GROUPS)
-		group_add(sc->group_active, cc);
+		group_assign(sc->group_active, cc);
+	else
+		group_assign(NULL, cc);
 }
 
 void