gc clientq inside groups, instead use the better maintained one per-screen

This commit is contained in:
okan 2019-03-07 13:14:41 +00:00
parent b26202724a
commit aa79351d2e
3 changed files with 40 additions and 28 deletions

View File

@ -121,7 +121,6 @@ TAILQ_HEAD(ignore_q, winname);
struct client_ctx {
TAILQ_ENTRY(client_ctx) entry;
TAILQ_ENTRY(client_ctx) group_entry;
struct screen_ctx *sc;
struct group_ctx *gc;
Window win;
@ -187,7 +186,6 @@ struct group_ctx {
struct screen_ctx *sc;
char *name;
int num;
struct client_q clientq;
};
TAILQ_HEAD(group_q, group_ctx);

View File

@ -183,9 +183,6 @@ client_remove(struct client_ctx *cc)
if (cc->flags & CLIENT_ACTIVE)
xu_ewmh_net_active_window(sc, None);
if (cc->gc != NULL)
TAILQ_REMOVE(&cc->gc->clientq, cc, group_entry);
while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) {
TAILQ_REMOVE(&cc->nameq, wn, entry);
free(wn->name);
@ -976,7 +973,9 @@ client_htile(struct client_ctx *cc)
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
TAILQ_FOREACH(ci, &sc->clientq, entry) {
if (ci->gc != cc->gc)
continue;
if (ci->flags & CLIENT_HIDDEN ||
ci->flags & CLIENT_IGNORE || (ci == cc) ||
ci->geom.x < area.x ||
@ -1005,7 +1004,9 @@ client_htile(struct client_ctx *cc)
x = area.x;
w = area.w / n;
h = area.h - mh;
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
TAILQ_FOREACH(ci, &sc->clientq, entry) {
if (ci->gc != cc->gc)
continue;
if (ci->flags & CLIENT_HIDDEN ||
ci->flags & CLIENT_IGNORE || (ci == cc) ||
ci->geom.x < area.x ||
@ -1044,7 +1045,9 @@ client_vtile(struct client_ctx *cc)
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
TAILQ_FOREACH(ci, &sc->clientq, entry) {
if (ci->gc != cc->gc)
continue;
if (ci->flags & CLIENT_HIDDEN ||
ci->flags & CLIENT_IGNORE || (ci == cc) ||
ci->geom.x < area.x ||
@ -1073,7 +1076,9 @@ client_vtile(struct client_ctx *cc)
y = area.y;
h = area.h / n;
w = area.w - mw;
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
TAILQ_FOREACH(ci, &sc->clientq, entry) {
if (ci->gc != cc->gc)
continue;
if (ci->flags & CLIENT_HIDDEN ||
ci->flags & CLIENT_IGNORE || (ci == cc) ||
ci->geom.x < area.x ||

47
group.c
View File

@ -40,28 +40,25 @@ static void group_setactive(struct group_ctx *);
void
group_assign(struct group_ctx *gc, struct client_ctx *cc)
{
if (cc->gc != NULL)
TAILQ_REMOVE(&cc->gc->clientq, cc, group_entry);
if ((gc != NULL) && (gc->num == 0))
gc = NULL;
cc->gc = gc;
if (cc->gc != NULL)
TAILQ_INSERT_TAIL(&gc->clientq, cc, group_entry);
xu_ewmh_net_wm_desktop(cc);
}
void
group_hide(struct group_ctx *gc)
{
struct screen_ctx *sc = gc->sc;
struct client_ctx *cc;
screen_updatestackingorder(gc->sc);
TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->gc != gc)
continue;
if (!(cc->flags & CLIENT_STICKY) &&
!(cc->flags & CLIENT_HIDDEN))
client_hide(cc);
@ -71,9 +68,12 @@ group_hide(struct group_ctx *gc)
void
group_show(struct group_ctx *gc)
{
struct screen_ctx *sc = gc->sc;
struct client_ctx *cc;
TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->gc != gc)
continue;
if (!(cc->flags & CLIENT_STICKY) &&
(cc->flags & CLIENT_HIDDEN))
client_show(cc);
@ -86,19 +86,24 @@ group_show(struct group_ctx *gc)
static void
group_restack(struct group_ctx *gc)
{
struct screen_ctx *sc = gc->sc;
struct client_ctx *cc;
Window *winlist;
int i, lastempty = -1;
int nwins = 0, highstack = 0;
TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->gc != gc)
continue;
if (cc->stackingorder > highstack)
highstack = cc->stackingorder;
}
winlist = xreallocarray(NULL, (highstack + 1), sizeof(*winlist));
/* Invert the stacking order for XRestackWindows(). */
TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->gc != gc)
continue;
winlist[highstack - cc->stackingorder] = cc->win;
nwins++;
}
@ -127,7 +132,6 @@ group_init(struct screen_ctx *sc, int num, const char *name)
gc->sc = sc;
gc->name = xstrdup(name);
gc->num = num;
TAILQ_INIT(&gc->clientq);
TAILQ_INSERT_TAIL(&sc->groupq, gc, entry);
@ -182,9 +186,12 @@ group_toggle_membership(struct client_ctx *cc)
int
group_holds_only_sticky(struct group_ctx *gc)
{
struct screen_ctx *sc = gc->sc;
struct client_ctx *cc;
TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->gc != gc)
continue;
if (!(cc->flags & CLIENT_STICKY))
return(0);
}
@ -194,9 +201,12 @@ group_holds_only_sticky(struct group_ctx *gc)
int
group_holds_only_hidden(struct group_ctx *gc)
{
struct screen_ctx *sc = gc->sc;
struct client_ctx *cc;
TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->gc != gc)
continue;
if (!(cc->flags & (CLIENT_HIDDEN | CLIENT_STICKY)))
return(0);
}
@ -225,12 +235,8 @@ group_toggle(struct screen_ctx *sc, int idx)
if (gc->num == idx) {
if (group_holds_only_hidden(gc))
group_show(gc);
else {
else
group_hide(gc);
/* make clients stick to empty group */
if (TAILQ_EMPTY(&gc->clientq))
group_setactive(gc);
}
}
}
}
@ -257,8 +263,11 @@ group_close(struct screen_ctx *sc, int idx)
TAILQ_FOREACH(gc, &sc->groupq, entry) {
if (gc->num == idx) {
TAILQ_FOREACH(cc, &gc->clientq, group_entry)
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->gc != gc)
continue;
client_close(cc);
}
}
}
}