From 2e16db28638cf0e78e6ddae11521a1f589179f67 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 4 Oct 2016 15:18:20 +0000 Subject: Turn CALMWM_NGROUPS define into variable, ngroups. --- xutil.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'xutil.c') diff --git a/xutil.c b/xutil.c index f2691ff..f1d66d6 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.106 2016/09/30 18:28:06 okan Exp $ + * $OpenBSD: xutil.c,v 1.107 2016/10/04 15:18:20 okan Exp $ */ #include @@ -131,19 +131,20 @@ xu_ewmh_net_desktop_geometry(struct screen_ctx *sc) void xu_ewmh_net_workarea(struct screen_ctx *sc) { - long workareas[CALMWM_NGROUPS][4]; - int i; - - for (i = 0; i < CALMWM_NGROUPS; i++) { - workareas[i][0] = sc->work.x; - workareas[i][1] = sc->work.y; - workareas[i][2] = sc->work.w; - workareas[i][3] = sc->work.h; + unsigned long *workarea; + int i, ngroups = Conf.ngroups; + + workarea = xreallocarray(NULL, ngroups * 4, sizeof(unsigned long)); + for (i = 0; i < ngroups; i++) { + workarea[4 * i + 0] = sc->work.x; + workarea[4 * i + 1] = sc->work.y; + workarea[4 * i + 2] = sc->work.w; + workarea[4 * i + 3] = sc->work.h; } - XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_WORKAREA], - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)workareas, - CALMWM_NGROUPS * 4); + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)workarea, + ngroups * 4); + free(workarea); } void @@ -223,7 +224,7 @@ xu_ewmh_net_wm_desktop_viewport(struct screen_ctx *sc) void xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *sc) { - long ndesks = CALMWM_NGROUPS; + long ndesks = Conf.ngroups; XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_NUMBER_OF_DESKTOPS], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&ndesks, 1); -- cgit v1.2.3-2-gb3c3