Hello @tech,

cwm(1) currently implements some rudimentary tiling via the
window-htile and window-vtile commands. The current behaviour is to
resize the master client to half of the screen width or height.

While this is a reasonable default, I find that I often want the master
window to be a little bit bigger than half my screen; particularly as
my most common use case for tiling is to have a browser as the master 
window and several terminals onscreen alongside it.

This adds a new configuration option to cwm(1) named masterpercent, 
which is an integer between zero and one hundred (non-inclusive) that
specifies the percentage of the screen that the master window should
take up. I'm not a huge fan of the name, and would be open to a better
suggestion. I've used the terminology I'm familiar with from dwm and
xmonad.

By default masterpercent is set to 50, preserving the current behaviour.

As an example of the usage, I have in my .cwmrc the line

    masterpercent 57

telling cwm to use 57% of the screen for the master window.

Thoughts?

Regards,
Joe

Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.362
diff -u -p -r1.362 calmwm.h
--- calmwm.h    8 Nov 2018 15:49:42 -0000       1.362
+++ calmwm.h    30 Jan 2019 18:15:51 -0000
@@ -299,6 +299,7 @@ struct conf {
        int                      stickygroups;
        int                      nameqlen;
        int                      bwidth;
+       int                      mpercent;
        int                      mamount;
        int                      snapdist;
        struct gap               gap;
Index: client.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/client.c,v
retrieving revision 1.247
diff -u -p -r1.247 client.c
--- client.c    13 Nov 2018 17:37:13 -0000      1.247
+++ client.c    30 Jan 2019 18:15:51 -0000
@@ -1007,7 +1007,7 @@ client_htile(struct client_ctx *cc)
        cc->geom.x = area.x;
        cc->geom.y = area.y;
        cc->geom.w = area.w - (cc->bwidth * 2);
-       cc->geom.h = (area.h - (cc->bwidth * 2)) / 2;
+       cc->geom.h = ((area.h - (cc->bwidth * 2)) * Conf.mpercent) / 100;
        client_resize(cc, 1);
        client_ptrwarp(cc);
 
@@ -1066,7 +1066,7 @@ client_vtile(struct client_ctx *cc)
        cc->flags &= ~CLIENT_VMAXIMIZED;
        cc->geom.x = area.x;
        cc->geom.y = area.y;
-       cc->geom.w = (area.w - (cc->bwidth * 2)) / 2;
+       cc->geom.w = ((area.w - (cc->bwidth * 2)) * Conf.mpercent) / 100;
        cc->geom.h = area.h - (cc->bwidth * 2);
        client_resize(cc, 1);
        client_ptrwarp(cc);
Index: conf.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.242
diff -u -p -r1.242 conf.c
--- conf.c      13 Nov 2018 17:37:13 -0000      1.242
+++ conf.c      30 Jan 2019 18:15:51 -0000
@@ -256,6 +256,7 @@ conf_init(struct conf *c)
        c->stickygroups = 0;
        c->bwidth = 1;
        c->mamount = 1;
+       c->mpercent = 50;
        c->snapdist = 0;
        c->ngroups = 10;
        c->nameqlen = 5;
Index: cwmrc.5
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.70
diff -u -p -r1.70 cwmrc.5
--- cwmrc.5     29 Dec 2017 20:03:46 -0000      1.70
+++ cwmrc.5     30 Jan 2019 18:15:51 -0000
@@ -212,6 +212,15 @@ Ignore, and do not warp to, windows with
 .Ar windowname
 when drawing borders and cycling through windows.
 .Pp
+.It Ic masterpercent Ar percentage
+Set the percentage of the screen the master client should
+be resized to when 
+.Ic window-htile
+or
+.Ic window-vtile
+is called.
+The default is 50 (half of the screen).
+.Pp
 .It Ic moveamount Ar pixels
 Set a default size for the keyboard movement bindings,
 in pixels.
@@ -330,11 +339,15 @@ Vertically maximize current window (gap 
 Horizontally maximize current window (gap + border honored).
 .It window-htile
 Current window is placed at the top of the screen, maximized
-horizontally and resized to half of the vertical screen space.
+horizontally and resized to 
+.Ar masterpercent
+of the vertical screen space.
 Other windows in its group share remaining screen space.
 .It window-vtile
 Current window is placed on the left of the screen, maximized vertically
-and resized to half of the horizontal screen space.
+and resized to 
+.Ar masterpercent
+of the horizontal screen space.
 Other windows in its group share remaining screen space.
 .It window-move
 Move current window.
Index: parse.y
===================================================================
RCS file: /cvs/xenocara/app/cwm/parse.y,v
retrieving revision 1.72
diff -u -p -r1.72 parse.y
--- parse.y     9 Nov 2018 16:00:54 -0000       1.72
+++ parse.y     30 Jan 2019 18:15:53 -0000
@@ -71,7 +71,7 @@ typedef struct {
 %token BINDKEY UNBINDKEY BINDMOUSE UNBINDMOUSE
 %token FONTNAME STICKY GAP
 %token AUTOGROUP COMMAND IGNORE WM
-%token YES NO BORDERWIDTH MOVEAMOUNT
+%token YES NO BORDERWIDTH MOVEAMOUNT MASTERPERCENT
 %token COLOR SNAPDIST
 %token ACTIVEBORDER INACTIVEBORDER URGENCYBORDER
 %token GROUPBORDER UNGROUPBORDER
@@ -122,6 +122,13 @@ main               : FONTNAME STRING               {
                        }
                        conf->bwidth = $2;
                }
+               | MASTERPERCENT NUMBER {
+                       if ($2 < 1 || $2 > 99) {
+                               yyerror("invalid masterpercent");
+                               YYERROR;
+                       }
+                       conf->mpercent = $2;
+               }
                | MOVEAMOUNT NUMBER {
                        if ($2 < 0 || $2 > INT_MAX) {
                                yyerror("invalid movemount");
@@ -318,6 +325,7 @@ lookup(char *s)
                { "groupborder",        GROUPBORDER},
                { "ignore",             IGNORE},
                { "inactiveborder",     INACTIVEBORDER},
+               { "masterpercent",      MASTERPERCENT},
                { "menubg",             MENUBG},
                { "menufg",             MENUFG},
                { "moveamount",         MOVEAMOUNT},

Reply via email to