summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2019-02-28 23:26:12 +0000
committerokan <okan>2019-02-28 23:26:12 +0000
commitae231f67d0ac54fb6281831c10972cc2f1f37acf (patch)
treeb555df0ddb4243ea8ade9a6ae688187184e21840
parent880b5cda3f36e0135632d6670717e9a964caf0ec (diff)
downloadcwm-ae231f67d0ac54fb6281831c10972cc2f1f37acf.tar.gz
cwm-ae231f67d0ac54fb6281831c10972cc2f1f37acf.tar.xz
cwm-ae231f67d0ac54fb6281831c10972cc2f1f37acf.zip
Move the group index (desktop number) check to the only 2 callers that require
checking due to ewmh.
-rw-r--r--group.c12
-rw-r--r--xevents.c8
2 files changed, 6 insertions, 14 deletions
diff --git a/group.c b/group.c
index b6ca7d5..0dc54ff 100644
--- a/group.c
+++ b/group.c
@@ -156,9 +156,6 @@ group_movetogroup(struct client_ctx *cc, int idx)
 	struct screen_ctx	*sc = cc->sc;
 	struct group_ctx	*gc;
 
-	if (idx < 0 || idx >= Conf.ngroups)
-		return;
-
 	TAILQ_FOREACH(gc, &sc->groupq, entry) {
 		if (gc->num == idx) {
 			if (cc->gc == gc)
@@ -216,9 +213,6 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
 {
 	struct group_ctx	*gc;
 
-	if (idx < 0 || idx >= Conf.ngroups)
-		return;
-
 	TAILQ_FOREACH(gc, &sc->groupq, entry) {
 		if (gc->num == idx) {
 			if (group_holds_only_hidden(gc))
@@ -238,9 +232,6 @@ group_only(struct screen_ctx *sc, int idx)
 {
 	struct group_ctx	*gc;
 
-	if (idx < 0 || idx >= Conf.ngroups)
-		return;
-
 	TAILQ_FOREACH(gc, &sc->groupq, entry) {
 		if (gc->num == idx)
 			group_show(gc);
@@ -255,9 +246,6 @@ group_close(struct screen_ctx *sc, int idx)
 	struct group_ctx	*gc;
 	struct client_ctx	*cc;
 
-	if (idx < 0 || idx >= Conf.ngroups)
-		return;
-
 	TAILQ_FOREACH(gc, &sc->groupq, entry) {
 		if (gc->num == idx) {
 			TAILQ_FOREACH(cc, &gc->clientq, group_entry)
diff --git a/xevents.c b/xevents.c
index 8fd65ff..2ef236d 100644
--- a/xevents.c
+++ b/xevents.c
@@ -408,7 +408,9 @@ xev_handle_clientmessage(XEvent *ee)
 			if (e->data.l[0] == (unsigned long)-1)
 				group_movetogroup(cc, 0);
 			else
-				group_movetogroup(cc, e->data.l[0]);
+				if (e->data.l[0] >= 0 &&
+				    e->data.l[0] < Conf.ngroups)
+					group_movetogroup(cc, e->data.l[0]);
 		}
 	} else if (e->message_type == ewmh[_NET_WM_STATE]) {
 		if ((cc = client_find(e->window)) != NULL) {
@@ -417,7 +419,9 @@ xev_handle_clientmessage(XEvent *ee)
 		}
 	} else if (e->message_type == ewmh[_NET_CURRENT_DESKTOP]) {
 		if ((sc = screen_find(e->window)) != NULL) {
-			group_only(sc, e->data.l[0]);
+			if (e->data.l[0] >= 0 &&
+			    e->data.l[0] < Conf.ngroups)
+				group_only(sc, e->data.l[0]);
 		}
 	}
 }