From 836c9f49d644e52395a12d0805260e070c999099 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 8 Oct 2014 12:48:51 +0000 Subject: [PATCH 1/2] make group_init work like other *_init's --- calmwm.h | 4 ++-- group.c | 25 ++++++++++++------------- screen.c | 4 +++- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/calmwm.h b/calmwm.h index 00d09bb..80e2554 100644 --- a/calmwm.h +++ b/calmwm.h @@ -202,9 +202,9 @@ TAILQ_HEAD(client_ctx_q, client_ctx); struct group_ctx { TAILQ_ENTRY(group_ctx) entry; struct screen_ctx *sc; - struct client_ctx_q clientq; char *name; int num; + struct client_ctx_q clientq; }; TAILQ_HEAD(group_ctx_q, group_ctx); @@ -410,7 +410,7 @@ void group_hide(struct group_ctx *); void group_hidetoggle(struct screen_ctx *, int); int group_holds_only_hidden(struct group_ctx *); int group_holds_only_sticky(struct group_ctx *); -void group_init(struct screen_ctx *); +void group_init(struct screen_ctx *, int); void group_movetogroup(struct client_ctx *, int); void group_only(struct screen_ctx *, int); void group_show(struct group_ctx *); diff --git a/group.c b/group.c index c7933f0..50fb82c 100644 --- a/group.c +++ b/group.c @@ -114,24 +114,23 @@ group_restack(struct group_ctx *gc) } void -group_init(struct screen_ctx *sc) +group_init(struct screen_ctx *sc, int num) { struct group_ctx *gc; - int i; - for (i = 0; i < CALMWM_NGROUPS; i++) { - gc = xcalloc(1, sizeof(*gc)); - gc->sc = sc; - TAILQ_INIT(&gc->clientq); - gc->name = xstrdup(num_to_name[i]); - gc->num = i; - TAILQ_INSERT_TAIL(&sc->groupq, gc, entry); - if (i == 1) - group_setactive(gc); - } + gc = xmalloc(sizeof(*gc)); + gc->sc = sc; + gc->name = xstrdup(num_to_name[num]); + gc->num = num; + TAILQ_INIT(&gc->clientq); + + TAILQ_INSERT_TAIL(&sc->groupq, gc, entry); + + if (num == 1) + group_setactive(gc); } -static void +void group_setactive(struct group_ctx *gc) { struct screen_ctx *sc = gc->sc; diff --git a/screen.c b/screen.c index 9beabb2..f9a4ca8 100644 --- a/screen.c +++ b/screen.c @@ -54,7 +54,9 @@ screen_init(int which) xu_ewmh_net_supported_wm_check(sc); screen_update_geometry(sc); - group_init(sc); + + for (i = 0; i < CALMWM_NGROUPS; i++) + group_init(sc, i); xu_ewmh_net_desktop_names(sc); xu_ewmh_net_wm_desktop_viewport(sc); From 9cada703b9772c5d9738c9bfa632e57678174025 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 8 Oct 2014 15:31:01 +0000 Subject: [PATCH 2/2] no need for calloc(1,.. here, malloc is fine since we initialize --- screen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/screen.c b/screen.c index f9a4ca8..18ffd05 100644 --- a/screen.c +++ b/screen.c @@ -38,7 +38,7 @@ screen_init(int which) XSetWindowAttributes rootattr; unsigned int nwins, i; - sc = xcalloc(1, sizeof(*sc)); + sc = xmalloc(sizeof(*sc)); TAILQ_INIT(&sc->clientq); TAILQ_INIT(&sc->regionq); @@ -48,6 +48,7 @@ screen_init(int which) sc->rootwin = RootWindow(X_Dpy, sc->which); sc->cycling = 0; sc->hideall = 0; + conf_screen(sc); xu_ewmh_net_supported(sc);