Here's another stab at the windowspawn global option.
It allows you to control where new windows are placed and can
be one of center, cursor, fullscreen, or random. If it's not
specified, the default behaviour is used (cursor).
It'd be nice if people could test this diff and provide some
feedback, such as "Yes, please" or "No, you moron!" ...
Thanks.
Index: calmwm.h
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.2
retrieving revision 1.1.1.1.4.4
diff -u -p -r1.2 -r1.1.1.1.4.4
--- calmwm.h 27 Jun 2009 08:20:23 -0000 1.2
+++ calmwm.h 22 Jul 2009 15:58:18 -0000 1.1.1.1.4.4
@@ -266,6 +266,12 @@ struct conf {
#define CONF_MAMOUNT 1
int mamount;
+#define CONF_WS_CURSOR 1
+#define CONF_WS_CENTER 2
+#define CONF_WS_RANDOM 3
+#define CONF_WS_FULLSCREEN 4
+ int windowspawn;
+
#define CONF_COLOR_ACTIVEBORDER "#CCCCCC"
#define CONF_COLOR_INACTIVEBORDER "#666666"
#define CONF_COLOR_GROUPBORDER "blue"
Index: client.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/client.c,v
retrieving revision 1.2
retrieving revision 1.1.1.1.4.10
diff -u -p -r1.2 -r1.1.1.1.4.10
--- client.c 27 Jun 2009 08:20:23 -0000 1.2
+++ client.c 22 Jul 2009 16:06:48 -0000 1.1.1.1.4.10
@@ -131,8 +131,12 @@ client_new(Window win, struct screen_ctx
client_gethints(cc);
client_update(cc);
- if (mapped)
+ if (mapped) {
group_autogroup(cc);
+ if ((Conf.windowspawn == CONF_WS_FULLSCREEN) &&
+ (cc->flags & CLIENT_IGNORE) == 0)
+ client_maximize(cc);
+ }
return (cc);
}
@@ -573,7 +577,21 @@ client_placecalc(struct client_ctx *cc)
int xmouse, ymouse, xorig, yorig;
int xmax, ymax;
- xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
+ switch (Conf.windowspawn) {
+ case CONF_WS_CENTER:
+ xmouse = sc->xmax / 2;
+ ymouse = sc->ymax / 2;
+ break;
+ case CONF_WS_RANDOM:
+ xmouse = rand() / (RAND_MAX / sc->xmax + 1);
+ ymouse = rand() / (RAND_MAX / sc->ymax + 1);
+ break;
+ case CONF_WS_CURSOR:
+ default:
+ xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
+ break;
+ }
+
if (HasXinerama) {
info = screen_find_xinerama(sc, xmouse, ymouse);
if (info == NULL)
Index: conf.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/conf.c,v
retrieving revision 1.2
retrieving revision 1.1.1.1.4.2
diff -u -p -r1.2 -r1.1.1.1.4.2
--- conf.c 27 Jun 2009 08:20:23 -0000 1.2
+++ conf.c 27 Jun 2009 08:25:51 -0000 1.1.1.1.4.2
@@ -99,6 +99,7 @@ conf_init(struct conf *c)
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: cwmrc.5
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.2
diff -u -p -r1.1.1.1 -r1.1.1.1.4.2
--- cwmrc.5 24 Jun 2009 12:35:33 -0000 1.1.1.1
+++ cwmrc.5 22 Jul 2009 16:00:46 -0000 1.1.1.1.4.2
@@ -192,6 +192,11 @@ The default behavior for new windows is
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 one of `center', `cursor' (the default), `fullscreen', or `random'.
.El
.Sh EXAMPLE CONFIGURATION
.Bd -literal
Index: parse.y
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/parse.y,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.5
diff -u -p -r1.1.1.1 -r1.1.1.1.4.5
--- parse.y 24 Jun 2009 12:35:33 -0000 1.1.1.1
+++ parse.y 22 Jul 2009 15:58:18 -0000 1.1.1.1.4.5
@@ -67,7 +67,7 @@ typedef struct {
%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,15 @@ main : FONTNAME STRING {
free($2);
free($3);
}
+ | WINDOWSPAWN STRING {
+ if (strcasecmp($2, "center") == 0)
+ conf->windowspawn = CONF_WS_CENTER;
+ else if (strcasecmp($2, "fullscreen") == 0)
+ conf->windowspawn = CONF_WS_FULLSCREEN;
+ else if (strcasecmp($2, "random") == 0)
+ conf->windowspawn = CONF_WS_RANDOM;
+ free($2);
+ }
;
color : COLOR colors
@@ -243,6 +252,7 @@ lookup(char *s)
{ "no", NO},
{ "sticky", STICKY},
{ "ungroupborder", UNGROUPBORDER},
+ { "windowspawn", WINDOWSPAWN},
{ "yes", YES}
};
const struct keywords *p;
@@ -535,6 +545,7 @@ parse_config(const char *filename, struc
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);