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).
This commit is contained in:
okan 2014-09-08 20:11:22 +00:00
parent a7f3f29ea9
commit 26ba152692
7 changed files with 25 additions and 28 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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,

View File

@ -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)

View File

@ -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;

View File

@ -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);