summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2014-09-08 20:11:22 +0000
committerokan <okan>2014-09-08 20:11:22 +0000
commit26ba1526929931660ac22757ac752f15d5b64fb2 (patch)
tree266554c068c841d567db0a0bbf67eda539ad606f
parenta7f3f29ea91dc06ad326d22a161f046aab03697e (diff)
downloadcwm-26ba1526929931660ac22757ac752f15d5b64fb2.tar.gz
cwm-26ba1526929931660ac22757ac752f15d5b64fb2.tar.xz
cwm-26ba1526929931660ac22757ac752f15d5b64fb2.zip
Remove duplicate client queue (mruq); instead, remove and take the
global Clientq and place it inside screen_ctx since every client belongs
to a screen, then use the same per screen clientq to track stacking
order (the sole reason for mruq).
-rw-r--r--calmwm.c1
-rw-r--r--calmwm.h9
-rw-r--r--client.c33
-rw-r--r--kbfunc.c2
-rw-r--r--mousefunc.c2
-rw-r--r--screen.c2
-rw-r--r--xutil.c4
7 files changed, 25 insertions, 28 deletions
diff --git a/calmwm.c b/calmwm.c
index 06029a2..f85c4c2 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -41,7 +41,6 @@ Atom				 cwmh[CWMH_NITEMS];
 Atom				 ewmh[EWMH_NITEMS];
 
 struct screen_ctx_q		 Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
-struct client_ctx_q		 Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
 
 int				 HasRandr, Randr_ev;
 struct conf			 Conf;
diff --git a/calmwm.h b/calmwm.h
index f4a79db..243be98 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -143,9 +143,8 @@ TAILQ_HEAD(winname_q, winname);
 TAILQ_HEAD(ignore_q, winname);
 
 struct client_ctx {
-	TAILQ_ENTRY(client_ctx) entry;
-	TAILQ_ENTRY(client_ctx) group_entry;
-	TAILQ_ENTRY(client_ctx) mru_entry;
+	TAILQ_ENTRY(client_ctx)	 entry;
+	TAILQ_ENTRY(client_ctx)	 group_entry;
 	struct screen_ctx	*sc;
 	Window			 win;
 	Colormap		 colormap;
@@ -199,7 +198,6 @@ struct client_ctx {
 	XWMHints		*wmh;
 };
 TAILQ_HEAD(client_ctx_q, client_ctx);
-TAILQ_HEAD(cycle_entry_q, client_ctx);
 
 struct group_ctx {
 	TAILQ_ENTRY(group_ctx)	 entry;
@@ -235,7 +233,7 @@ struct screen_ctx {
 	struct geom		 view; /* viewable area */
 	struct geom		 work; /* workable area, gap-applied */
 	struct gap		 gap;
-	struct cycle_entry_q	 mruq;
+	struct client_ctx_q	 clientq;
 	struct region_ctx_q	 regionq;
 	XftColor		 xftcolor[CWM_COLOR_NITEMS];
 	XftDraw			*xftdraw;
@@ -315,7 +313,6 @@ struct mwm_hints {
 extern Display				*X_Dpy;
 extern Time				 Last_Event_Time;
 extern struct screen_ctx_q		 Screenq;
-extern struct client_ctx_q		 Clientq;
 extern struct conf			 Conf;
 extern const char			*homedir;
 extern int				 HasRandr, Randr_ev;
diff --git a/client.c b/client.c
index 54c8ecb..1fd6824 100644
--- a/client.c
+++ b/client.c
@@ -45,11 +45,14 @@ struct client_ctx	*curcc = NULL;
 struct client_ctx *
 client_find(Window win)
 {
+	struct screen_ctx	*sc;
 	struct client_ctx	*cc;
 
-	TAILQ_FOREACH(cc, &Clientq, entry) {
-		if (cc->win == win)
-			return(cc);
+	TAILQ_FOREACH(sc, &Screenq, entry) {
+		TAILQ_FOREACH(cc, &sc->clientq, entry) {
+			if (cc->win == win)
+				return(cc);
+		}
 	}
 	return(NULL);
 }
@@ -126,8 +129,7 @@ client_init(Window win, struct screen_ctx *sc)
 
 	(state == IconicState) ? client_hide(cc) : client_unhide(cc);
 
-	TAILQ_INSERT_TAIL(&sc->mruq, cc, mru_entry);
-	TAILQ_INSERT_TAIL(&Clientq, cc, entry);
+	TAILQ_INSERT_TAIL(&sc->clientq, cc, entry);
 
 	xu_ewmh_net_client_list(sc);
 	xu_ewmh_restore_net_wm_state(cc);
@@ -147,8 +149,7 @@ client_delete(struct client_ctx *cc)
 	struct screen_ctx	*sc = cc->sc;
 	struct winname		*wn;
 
-	TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
-	TAILQ_REMOVE(&Clientq, cc, entry);
+	TAILQ_REMOVE(&sc->clientq, cc, entry);
 
 	xu_ewmh_net_client_list(sc);
 
@@ -641,13 +642,13 @@ client_cycle(struct screen_ctx *sc, int flags)
 	oldcc = client_current();
 
 	/* If no windows then you cant cycle */
-	if (TAILQ_EMPTY(&sc->mruq))
+	if (TAILQ_EMPTY(&sc->clientq))
 		return;
 
 	if (oldcc == NULL)
 		oldcc = (flags & CWM_RCYCLE ?
-		    TAILQ_LAST(&sc->mruq, cycle_entry_q) :
-		    TAILQ_FIRST(&sc->mruq));
+		    TAILQ_LAST(&sc->clientq, client_ctx_q) :
+		    TAILQ_FIRST(&sc->clientq));
 
 	newcc = oldcc;
 	while (again) {
@@ -696,8 +697,8 @@ client_mrunext(struct client_ctx *cc)
 	struct screen_ctx	*sc = cc->sc;
 	struct client_ctx	*ccc;
 
-	return((ccc = TAILQ_NEXT(cc, mru_entry)) != NULL ?
-	    ccc : TAILQ_FIRST(&sc->mruq));
+	return((ccc = TAILQ_NEXT(cc, entry)) != NULL ?
+	    ccc : TAILQ_FIRST(&sc->clientq));
 }
 
 static struct client_ctx *
@@ -706,8 +707,8 @@ client_mruprev(struct client_ctx *cc)
 	struct screen_ctx	*sc = cc->sc;
 	struct client_ctx	*ccc;
 
-	return((ccc = TAILQ_PREV(cc, cycle_entry_q, mru_entry)) != NULL ?
-	    ccc : TAILQ_LAST(&sc->mruq, cycle_entry_q));
+	return((ccc = TAILQ_PREV(cc, client_ctx_q, entry)) != NULL ?
+	    ccc : TAILQ_LAST(&sc->clientq, client_ctx_q));
 }
 
 static void
@@ -765,8 +766,8 @@ client_mtf(struct client_ctx *cc)
 {
 	struct screen_ctx	*sc = cc->sc;
 
-	TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
-	TAILQ_INSERT_HEAD(&sc->mruq, cc, mru_entry);
+	TAILQ_REMOVE(&sc->clientq, cc, entry);
+	TAILQ_INSERT_HEAD(&sc->clientq, cc, entry);
 }
 
 void
diff --git a/kbfunc.c b/kbfunc.c
index 81133b2..8c7d85a 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -151,7 +151,7 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg)
 	old_cc = client_current();
 
 	TAILQ_INIT(&menuq);
-	TAILQ_FOREACH(cc, &Clientq, entry)
+	TAILQ_FOREACH(cc, &sc->clientq, entry)
 		menuq_add(&menuq, cc, "%s", cc->name);
 
 	if ((mi = menu_filter(sc, &menuq, "window", NULL, 0,
diff --git a/mousefunc.c b/mousefunc.c
index 421b743..b46fcfc 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -219,7 +219,7 @@ mousefunc_menu_unhide(struct client_ctx *cc, union arg *arg)
 	old_cc = client_current();
 
 	TAILQ_INIT(&menuq);
-	TAILQ_FOREACH(cc, &Clientq, entry) {
+	TAILQ_FOREACH(cc, &sc->clientq, entry) {
 		if (cc->flags & CLIENT_HIDDEN) {
 			wname = (cc->label) ? cc->label : cc->name;
 			if (wname == NULL)
diff --git a/screen.c b/screen.c
index 1706f5b..3c7c41b 100644
--- a/screen.c
+++ b/screen.c
@@ -40,7 +40,7 @@ screen_init(int which)
 
 	sc = xcalloc(1, sizeof(*sc));
 
-	TAILQ_INIT(&sc->mruq);
+	TAILQ_INIT(&sc->clientq);
 	TAILQ_INIT(&sc->regionq);
 
 	sc->which = which;
diff --git a/xutil.c b/xutil.c
index b490652..199119f 100644
--- a/xutil.c
+++ b/xutil.c
@@ -214,13 +214,13 @@ xu_ewmh_net_client_list(struct screen_ctx *sc)
 	Window			*winlist;
 	int			 i = 0, j = 0;
 
-	TAILQ_FOREACH(cc, &Clientq, entry)
+	TAILQ_FOREACH(cc, &sc->clientq, entry)
 		i++;
 	if (i == 0)
 		return;
 
 	winlist = xcalloc(i, sizeof(*winlist));
-	TAILQ_FOREACH(cc, &Clientq, entry)
+	TAILQ_FOREACH(cc, &sc->clientq, entry)
 		winlist[j++] = cc->win;
 	XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST],
 	    XA_WINDOW, 32, PropModeReplace, (unsigned char *)winlist, i);