From 65f7d6fe84c11c78932bd9c10bce0ed3ded143c8 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 25 Aug 2014 14:31:22 +0000 Subject: 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. --- xutil.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'xutil.c') diff --git a/xutil.c b/xutil.c index a5c1302..525c231 100644 --- a/xutil.c +++ b/xutil.c @@ -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: xutil.c,v 1.88 2014/08/25 12:49:19 okan Exp $ + * $OpenBSD: xutil.c,v 1.89 2014/08/25 14:31:22 okan Exp $ */ #include @@ -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 */ -- cgit v1.2.3-2-gb3c3