summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2014-08-25 14:31:22 +0000
committerokan <okan>2014-08-25 14:31:22 +0000
commit3b99d5357667095b3b89e2c41c2cb17d07537b42 (patch)
treea9f43a884779d14f94e8b64323740fb276694ca7
parent7314a3aefd33e901cfa1bd4a48eb4e75be4c01e2 (diff)
downloadcwm-3b99d5357667095b3b89e2c41c2cb17d07537b42.tar.gz
cwm-3b99d5357667095b3b89e2c41c2cb17d07537b42.tar.xz
cwm-3b99d5357667095b3b89e2c41c2cb17d07537b42.zip
Since the flatting out of sc->group_names is only for setting
NET_DESKTOP_NAMES, merge the helper into xu_ewmh_net_desktop_names,
where we actually set the property.
-rw-r--r--calmwm.h3
-rw-r--r--group.c26
-rw-r--r--xutil.c20
3 files changed, 21 insertions, 28 deletions
diff --git a/calmwm.h b/calmwm.h
index 0cd1685..203f882 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -545,8 +545,7 @@ void			 xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *);
 void			 xu_ewmh_net_showing_desktop(struct screen_ctx *);
 void			 xu_ewmh_net_virtual_roots(struct screen_ctx *);
 void			 xu_ewmh_net_current_desktop(struct screen_ctx *, long);
-void			 xu_ewmh_net_desktop_names(struct screen_ctx *, char *,
-			     int);
+void			 xu_ewmh_net_desktop_names(struct screen_ctx *);
 
 void			 xu_ewmh_net_wm_desktop(struct client_ctx *);
 Atom 			*xu_ewmh_get_net_wm_state(struct client_ctx *, int *);
diff --git a/group.c b/group.c
index 3657fad..e4567ee 100644
--- a/group.c
+++ b/group.c
@@ -38,7 +38,6 @@ static void		 group_show(struct screen_ctx *, struct group_ctx *);
 static void		 group_restack(struct screen_ctx *, struct group_ctx *);
 static int		 group_hidden_state(struct group_ctx *);
 static void		 group_setactive(struct screen_ctx *, long);
-static void		 group_set_names(struct screen_ctx *);
 
 const char *num_to_name[] = {
 	"nogroup", "one", "two", "three", "four", "five", "six",
@@ -427,28 +426,7 @@ group_update_names(struct screen_ctx *sc)
 
 	sc->group_names = strings;
 	sc->group_nonames = n;
-	if (setnames)
-		group_set_names(sc);
-}
 
-static void
-group_set_names(struct screen_ctx *sc)
-{
-	char		*p, *q;
-	size_t		 len = 0, tlen, slen;
-	int		 i;
-
-	for (i = 0; i < sc->group_nonames; i++)
-		len += strlen(sc->group_names[i]) + 1;
-	q = p = xcalloc(len, sizeof(*p));
-
-	tlen = len;
-	for (i = 0; i < sc->group_nonames; i++) {
-		slen = strlen(sc->group_names[i]) + 1;
-		(void)strlcpy(q, sc->group_names[i], tlen);
-		tlen -= slen;
-		q += slen;
-	}
-
-	xu_ewmh_net_desktop_names(sc, p, len);
+	if (setnames)
+		xu_ewmh_net_desktop_names(sc);
 }
diff --git a/xutil.c b/xutil.c
index b61b0ee..cafd793 100644
--- a/xutil.c
+++ b/xutil.c
@@ -281,10 +281,26 @@ xu_ewmh_net_current_desktop(struct screen_ctx *sc, long idx)
 }
 
 void
-xu_ewmh_net_desktop_names(struct screen_ctx *sc, char *data, int n)
+xu_ewmh_net_desktop_names(struct screen_ctx *sc)
 {
+	char		*p, *q;
+	size_t		 len = 0, tlen, slen;
+	int		 i;
+
+	for (i = 0; i < sc->group_nonames; i++)
+		len += strlen(sc->group_names[i]) + 1;
+	q = p = xcalloc(len, sizeof(*p));
+
+	tlen = len;
+	for (i = 0; i < sc->group_nonames; i++) {
+		slen = strlen(sc->group_names[i]) + 1;
+		(void)strlcpy(q, sc->group_names[i], tlen);
+		tlen -= slen;
+		q += slen;
+	}
+
 	XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
-	    cwmh[UTF8_STRING], 8, PropModeReplace, (unsigned char *)data, n);
+	    cwmh[UTF8_STRING], 8, PropModeReplace, (unsigned char *)p, len);
 }
 
 /* Application Window Properties */