aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2016-10-04 15:18:20 +0000
committerokan2016-10-04 15:18:20 +0000
commit2e16db28638cf0e78e6ddae11521a1f589179f67 (patch)
treef968e38ac24cbd0b42a301ffcc7cefd2a5052415
parentda816a4a2336765be3b75ca8c08375463fdf31b8 (diff)
downloadcwm-2e16db28638cf0e78e6ddae11521a1f589179f67.tar.gz
Turn CALMWM_NGROUPS define into variable, ngroups.
Diffstat (limited to '')
-rw-r--r--calmwm.h4
-rw-r--r--conf.c3
-rw-r--r--group.c10
-rw-r--r--screen.c4
-rw-r--r--xutil.c27
5 files changed, 25 insertions, 23 deletions
diff --git a/calmwm.h b/calmwm.h
index c337835..b70c4db 100644
--- a/calmwm.h
+++ b/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.321 2016/10/03 18:43:49 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.322 2016/10/04 15:18:20 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -235,7 +235,6 @@ struct screen_ctx {
struct gap gap;
struct client_ctx_q clientq;
struct region_ctx_q regionq;
-#define CALMWM_NGROUPS 10
struct group_ctx_q groupq;
struct group_ctx *group_active;
struct {
@@ -283,6 +282,7 @@ struct conf {
struct autogroupwin_q autogroupq;
struct ignore_q ignoreq;
struct cmd_q cmdq;
+ int ngroups;
int stickygroups;
int bwidth;
int mamount;
diff --git a/conf.c b/conf.c
index b62e208..156211d 100644
--- a/conf.c
+++ b/conf.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: conf.c,v 1.210 2016/10/03 18:43:49 okan Exp $
+ * $OpenBSD: conf.c,v 1.211 2016/10/04 15:18:20 okan Exp $
*/
#include <sys/types.h>
@@ -258,6 +258,7 @@ conf_init(struct conf *c)
c->bwidth = 1;
c->mamount = 1;
c->snapdist = 0;
+ c->ngroups = 10;
TAILQ_INIT(&c->ignoreq);
TAILQ_INIT(&c->cmdq);
diff --git a/group.c b/group.c
index 93c72b9..abf3b7b 100644
--- a/group.c
+++ b/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.122 2016/09/02 16:07:11 okan Exp $
+ * $OpenBSD: group.c,v 1.123 2016/10/04 15:18:20 okan Exp $
*/
#include <sys/types.h>
@@ -154,7 +154,7 @@ group_movetogroup(struct client_ctx *cc, int idx)
struct screen_ctx *sc = cc->sc;
struct group_ctx *gc;
- if (idx < 0 || idx >= CALMWM_NGROUPS)
+ if (idx < 0 || idx >= Conf.ngroups)
errx(1, "group_movetogroup: index out of range (%d)", idx);
TAILQ_FOREACH(gc, &sc->groupq, entry) {
@@ -222,7 +222,7 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
{
struct group_ctx *gc;
- if (idx < 0 || idx >= CALMWM_NGROUPS)
+ if (idx < 0 || idx >= Conf.ngroups)
errx(1, "group_hidetoggle: index out of range (%d)", idx);
TAILQ_FOREACH(gc, &sc->groupq, entry) {
@@ -245,7 +245,7 @@ group_only(struct screen_ctx *sc, int idx)
{
struct group_ctx *gc;
- if (idx < 0 || idx >= CALMWM_NGROUPS)
+ if (idx < 0 || idx >= Conf.ngroups)
errx(1, "group_only: index out of range (%d)", idx);
TAILQ_FOREACH(gc, &sc->groupq, entry) {
@@ -335,7 +335,7 @@ group_restore(struct client_ctx *cc)
return(0);
num = (*grpnum == -1) ? 0 : *grpnum;
- num = MIN(num, (CALMWM_NGROUPS - 1));
+ num = MIN(num, (Conf.ngroups - 1));
XFree(grpnum);
TAILQ_FOREACH(gc, &sc->groupq, entry) {
diff --git a/screen.c b/screen.c
index 9f3eb47..660d9ff 100644
--- a/screen.c
+++ b/screen.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: screen.c,v 1.80 2016/09/16 14:32:02 okan Exp $
+ * $OpenBSD: screen.c,v 1.81 2016/10/04 15:18:20 okan Exp $
*/
#include <sys/types.h>
@@ -57,7 +57,7 @@ screen_init(int which)
screen_update_geometry(sc);
- for (i = 0; i < CALMWM_NGROUPS; i++)
+ for (i = 0; i < Conf.ngroups; i++)
group_init(sc, i);
xu_ewmh_net_desktop_names(sc);
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 <sys/types.h>
@@ -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);