summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2019-02-28 23:20:52 +0000
committerokan <okan>2019-02-28 23:20:52 +0000
commit880b5cda3f36e0135632d6670717e9a964caf0ec (patch)
treedc10318fbfd2d7c8eb5f092d1d36a6e2b69a4220
parent8cd6d1154c6e5198403270a66fffb8a4f0c56cf6 (diff)
downloadcwm-880b5cda3f36e0135632d6670717e9a964caf0ec.tar.gz
cwm-880b5cda3f36e0135632d6670717e9a964caf0ec.tar.xz
cwm-880b5cda3f36e0135632d6670717e9a964caf0ec.zip
Ensure we don't action on the last group when the requested one is not found.
-rw-r--r--group.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/group.c b/group.c
index 666186b..b6ca7d5 100644
--- a/group.c
+++ b/group.c
@@ -160,15 +160,14 @@ group_movetogroup(struct client_ctx *cc, int idx)
 		return;
 
 	TAILQ_FOREACH(gc, &sc->groupq, entry) {
-		if (gc->num == idx)
-			break;
+		if (gc->num == idx) {
+			if (cc->gc == gc)
+				return;
+			if (gc->num != 0 && group_holds_only_hidden(gc))
+				client_hide(cc);
+			group_assign(gc, cc);
+		}
 	}
-
-	if (cc->gc == gc)
-		return;
-	if (gc->num != 0 && group_holds_only_hidden(gc))
-		client_hide(cc);
-	group_assign(gc, cc);
 }
 
 void
@@ -221,17 +220,16 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
 		return;
 
 	TAILQ_FOREACH(gc, &sc->groupq, entry) {
-		if (gc->num == idx)
-			break;
-	}
-
-	if (group_holds_only_hidden(gc))
-		group_show(gc);
-	else {
-		group_hide(gc);
-		/* make clients stick to empty group */
-		if (TAILQ_EMPTY(&gc->clientq))
-			group_setactive(gc);
+		if (gc->num == idx) {
+			if (group_holds_only_hidden(gc))
+				group_show(gc);
+			else {
+				group_hide(gc);
+				/* make clients stick to empty group */
+				if (TAILQ_EMPTY(&gc->clientq))
+					group_setactive(gc);
+			}
+		}
 	}
 }