summaryrefslogtreecommitdiff
path: root/app/cwm
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2014-09-07 17:27:21 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2014-09-07 17:27:21 +0000
commit54fb5306cfeff5053aa6ae0e3932f39eca58ef29 (patch)
treec0a49e8d18c50eb8ef6c35ea4b37d30255f1033f /app/cwm
parent3a2f60905a4b499ee9eae25ac13651c6bc4994bc (diff)
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 'app/cwm')
-rw-r--r--app/cwm/calmwm.h3
-rw-r--r--app/cwm/group.c32
2 files changed, 24 insertions, 11 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index 3528a0ae4..6dd3317da 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.268 2014/09/06 16:14:35 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.269 2014/09/07 17:27:20 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -240,7 +240,6 @@ struct screen_ctx {
XftDraw *xftdraw;
XftFont *xftfont;
#define CALMWM_NGROUPS 10
- struct group_ctx groups[CALMWM_NGROUPS];
struct group_ctx_q groupq;
int group_hideall;
struct group_ctx *group_active;
diff --git a/app/cwm/group.c b/app/cwm/group.c
index 6377d79ef..bf9864cb8 100644
--- a/app/cwm/group.c
+++ b/app/cwm/group.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: group.c,v 1.98 2014/09/06 16:08:58 okan Exp $
+ * $OpenBSD: group.c,v 1.99 2014/09/07 17:27:20 okan Exp $
*/
#include <sys/param.h>
@@ -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);