A new (simplified) diff based on some feedback ...
> This diff adds a new configuration option to cwm(1) called windowspawn
> that controls where new windows are placed. It can be one of `center',
> `cursor' (the default) or `random'.
Index: OpenBSD/xenocara/app/cwm/calmwm.h
diff -u OpenBSD/xenocara/app/cwm/calmwm.h:1.1
OpenBSD/xenocara/app/cwm/calmwm.h:1.2
--- OpenBSD/xenocara/app/cwm/calmwm.h:1.1 Wed Jun 17 11:18:34 2009
+++ OpenBSD/xenocara/app/cwm/calmwm.h Wed Jun 17 11:29:15 2009
@@ -260,6 +260,11 @@
#define CONF_MAMOUNT 1
int mamount;
+#define CONF_WS_CURSOR 1
+#define CONF_WS_CENTER 2
+#define CONF_WS_RANDOM 3
+ int windowspawn;
+
#define CONF_COLOR_ACTIVEBORDER "#CCCCCC"
#define CONF_COLOR_INACTIVEBORDER "#666666"
#define CONF_COLOR_GROUPBORDER "blue"
Index: OpenBSD/xenocara/app/cwm/client.c
diff -u OpenBSD/xenocara/app/cwm/client.c:1.1
OpenBSD/xenocara/app/cwm/client.c:1.2
--- OpenBSD/xenocara/app/cwm/client.c:1.1 Wed Jun 17 11:18:34 2009
+++ OpenBSD/xenocara/app/cwm/client.c Wed Jun 17 11:29:15 2009
@@ -582,7 +582,17 @@
int xmouse, ymouse, xorig, yorig;
int xmax, ymax;
- xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
+ if (Conf.windowspawn == CONF_WS_RANDOM) {
+ xmouse = rand() / (RAND_MAX / sc->xmax + 1);
+ ymouse = rand() / (RAND_MAX / sc->ymax + 1);
+ }
+ else if (Conf.windowspawn == CONF_WS_CENTER) {
+ xmouse = sc->xmax / 2;
+ ymouse = sc->ymax / 2;
+ }
+ else
+ xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
+
if (HasXinerama) {
info = screen_find_xinerama(sc, xmouse, ymouse);
if (info == NULL)
Index: OpenBSD/xenocara/app/cwm/conf.c
diff -u OpenBSD/xenocara/app/cwm/conf.c:1.1 OpenBSD/xenocara/app/cwm/conf.c:1.2
--- OpenBSD/xenocara/app/cwm/conf.c:1.1 Wed Jun 17 11:18:34 2009
+++ OpenBSD/xenocara/app/cwm/conf.c Wed Jun 17 11:29:15 2009
@@ -98,6 +98,7 @@
c->flags = 0;
c->bwidth = CONF_BWIDTH;
c->mamount = CONF_MAMOUNT;
+ c->windowspawn = CONF_WS_CURSOR;
TAILQ_INIT(&c->ignoreq);
TAILQ_INIT(&c->cmdq);
Index: OpenBSD/xenocara/app/cwm/cwmrc.5
diff -u OpenBSD/xenocara/app/cwm/cwmrc.5:1.1
OpenBSD/xenocara/app/cwm/cwmrc.5:1.2
--- OpenBSD/xenocara/app/cwm/cwmrc.5:1.1 Wed Jun 17 11:18:34 2009
+++ OpenBSD/xenocara/app/cwm/cwmrc.5 Wed Jun 17 11:29:15 2009
@@ -192,6 +192,11 @@
By enabling sticky group mode,
.Xr cwm 1
will assign new windows to the currently selected group.
+.Pp
+.It Ic windowspawn Ar where
+Control the placement of new windows.
+.Ar where
+can be center, random, or cursor (default).
.El
.Sh EXAMPLE CONFIGURATION
.Bd -literal
Index: OpenBSD/xenocara/app/cwm/parse.y
diff -u OpenBSD/xenocara/app/cwm/parse.y:1.1
OpenBSD/xenocara/app/cwm/parse.y:1.3
--- OpenBSD/xenocara/app/cwm/parse.y:1.1 Wed Jun 17 11:18:34 2009
+++ OpenBSD/xenocara/app/cwm/parse.y Wed Jun 17 11:35:41 2009
@@ -67,7 +67,7 @@
%token FONTNAME STICKY GAP MOUSEBIND
%token AUTOGROUP BIND COMMAND IGNORE
%token YES NO BORDERWIDTH MOVEAMOUNT
-%token COLOR
+%token WINDOWSPAWN COLOR
%token ACTIVEBORDER INACTIVEBORDER
%token GROUPBORDER UNGROUPBORDER
%token ERROR
@@ -173,6 +173,13 @@
free($2);
free($3);
}
+ | WINDOWSPAWN STRING {
+ if (strcasecmp($2, "random") == 0)
+ conf->windowspawn = CONF_WS_RANDOM;
+ else if (strcasecmp($2, "center") == 0)
+ conf->windowspawn = CONF_WS_CENTER;
+ free($2);
+ }
;
color : COLOR colors
@@ -243,6 +250,7 @@
{ "no", NO},
{ "sticky", STICKY},
{ "ungroupborder", UNGROUPBORDER},
+ { "windowspawn", WINDOWSPAWN},
{ "yes", YES}
};
const struct keywords *p;
@@ -535,6 +543,7 @@
xconf->flags = conf->flags;
xconf->bwidth = conf->bwidth;
xconf->mamount = conf->mamount;
+ xconf->windowspawn = conf->windowspawn;
while ((cmd = TAILQ_FIRST(&conf->cmdq)) != NULL) {
TAILQ_REMOVE(&conf->cmdq, cmd, entry);