diff options
author | okan <okan> | 2014-09-07 17:27:20 +0000 |
---|---|---|
committer | okan <okan> | 2014-09-07 17:27:20 +0000 |
commit | 78e0f2122580291206b5c9c3d07db9663f409c0b (patch) | |
tree | 7a1e8f13256204e1b6aefb9878e076fe902c234b /group.c | |
parent | f7af0ebd7267cdfd4e7b9c12bb910992f1a094e5 (diff) | |
download | cwm-78e0f2122580291206b5c9c3d07db9663f409c0b.tar.gz cwm-78e0f2122580291206b5c9c3d07db9663f409c0b.tar.xz cwm-78e0f2122580291206b5c9c3d07db9663f409c0b.zip |
Get rid of a redundant array of groups per screen; we already have a
link to the group queue for each screen.
Diffstat (limited to 'group.c')
-rw-r--r-- | group.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/group.c b/group.c index d1ae4f4..dcea84f 100644 --- a/group.c +++ b/group.c @@ -116,16 +116,18 @@ group_restack(struct screen_ctx *sc, struct group_ctx *gc) void group_init(struct screen_ctx *sc) { - int i; + struct group_ctx *gc; + int i; TAILQ_INIT(&sc->groupq); sc->group_hideall = 0; for (i = 0; i < CALMWM_NGROUPS; i++) { - TAILQ_INIT(&sc->groups[i].clients); - sc->groups[i].name = xstrdup(num_to_name[i]); - sc->groups[i].num = i; - TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry); + gc = xcalloc(1, sizeof(*gc)); + TAILQ_INIT(&gc->clients); + gc->name = xstrdup(num_to_name[i]); + gc->num = i; + TAILQ_INSERT_TAIL(&sc->groupq, gc, entry); } xu_ewmh_net_desktop_names(sc); @@ -140,7 +142,13 @@ group_init(struct screen_ctx *sc) static void group_setactive(struct screen_ctx *sc, long idx) { - sc->group_active = &sc->groups[idx]; + struct group_ctx *gc; + + TAILQ_FOREACH(gc, &sc->groupq, entry) { + if (gc->num == idx) + break; + } + sc->group_active = gc; xu_ewmh_net_current_desktop(sc, idx); } @@ -154,7 +162,10 @@ group_movetogroup(struct client_ctx *cc, int idx) if (idx < 0 || idx >= CALMWM_NGROUPS) errx(1, "group_movetogroup: index out of range (%d)", idx); - gc = &sc->groups[idx]; + TAILQ_FOREACH(gc, &sc->groupq, entry) { + if (gc->num == idx) + break; + } if (cc->group == gc) return; @@ -220,7 +231,10 @@ group_hidetoggle(struct screen_ctx *sc, int idx) if (idx < 0 || idx >= CALMWM_NGROUPS) errx(1, "group_hidetoggle: index out of range (%d)", idx); - gc = &sc->groups[idx]; + TAILQ_FOREACH(gc, &sc->groupq, entry) { + if (gc->num == idx) + break; + } if (group_hidden_state(gc)) group_show(sc, gc); |