PATCH: configurable tiling in cwm(1)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PATCH: configurable tiling in cwm(1)

Uwe Werler
Hello @tech,

with this diff https://marc.info/?l=openbsd-tech&m=149192690925713&w=2 the
behaviour of cwm changed so vtile and htile always use 50% of the screen.

This is a reasonable default but sometimes I want to have the master windows
be bigger.

Inspired by this patch https://marc.info/?l=openbsd-tech&m=154887686615696&w=2
I suggest the following diff.

This adds two new config options "htile percent" and "vtile percent" which
define how much of the screen the current windows should occupy as the master
window. If set to "0" then the old behaviour is restored where the current
vertical or horizontal size of the window defines the size of the master
window. If unset the current behaviour is unchaged that means the master
windows uses half of the screen size.

For example in .cwmrc:

htile 66
vtile 0

For window-htile the master window will occupy 66% of the screen high or for
window-vtile the current window width defines the screen width of the master
window.

Any thoughts?

Regards Uwe


Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.374
diff -u -p -r1.374 calmwm.h
--- calmwm.h 24 Mar 2020 14:47:29 -0000 1.374
+++ calmwm.h 27 Mar 2020 00:09:43 -0000
@@ -291,6 +291,8 @@ struct conf {
  int bwidth;
  int mamount;
  int snapdist;
+ int htile;
+ int vtile;
  struct gap gap;
  char *color[CWM_COLOR_NITEMS];
  char *font;
Index: client.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/client.c,v
retrieving revision 1.262
diff -u -p -r1.262 client.c
--- client.c 24 Mar 2020 14:47:29 -0000 1.262
+++ client.c 27 Mar 2020 00:09:43 -0000
@@ -940,7 +940,8 @@ 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;
+  if (Conf.htile > 0)
+ cc->geom.h = ((area.h - (cc->bwidth * 2)) * Conf.htile) / 100;
  client_resize(cc, 1);
  client_ptr_warp(cc);
 
@@ -1007,7 +1008,8 @@ 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;
+  if (Conf.vtile > 0)
+ cc->geom.w = ((area.w - (cc->bwidth * 2)) * Conf.vtile) / 100;
  cc->geom.h = area.h - (cc->bwidth * 2);
  client_resize(cc, 1);
  client_ptr_warp(cc);
Index: conf.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.251
diff -u -p -r1.251 conf.c
--- conf.c 27 Feb 2020 14:56:39 -0000 1.251
+++ conf.c 27 Mar 2020 00:09:43 -0000
@@ -281,6 +281,8 @@ conf_init(struct conf *c)
  c->stickygroups = 0;
  c->bwidth = 1;
  c->mamount = 1;
+ c->htile = 50;
+ c->vtile = 50;
  c->snapdist = 0;
  c->ngroups = 0;
  c->nameqlen = 5;
Index: cwmrc.5
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.75
diff -u -p -r1.75 cwmrc.5
--- cwmrc.5 13 Mar 2020 20:50:07 -0000 1.75
+++ cwmrc.5 27 Mar 2020 00:09:43 -0000
@@ -183,6 +183,11 @@ This
 can be used for applications such as
 .Xr xclock 1 ,
 where the user may wish to remain visible.
+.It Ic htile Ar percent
+The amount of the screen the master window should be resized to when
+.Ic window-htile
+is called. If set to 0 then the size is the vertical size of current current
+window.
 .It Ic ignore Ar windowname
 Ignore, and do not warp to, windows with the name
 .Ar windowname
@@ -216,6 +221,11 @@ A special
 keyword
 .Dq all
 can be used to unbind all buttons.
+.It Ic vtile Ar percent
+The amount of the screen the master window should be resized to when
+.Ic window-vtile
+is called. If set to 0 then the size is the horizontal size of the current
+window.
 .It Ic wm Ar name path
 Every
 .Ar name
@@ -303,11 +313,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 htile
+(default half) 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 vtile
+(default half) 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 27 Mar 2020 00:09:43 -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 HTILE VTILE
 %token COLOR SNAPDIST
 %token ACTIVEBORDER INACTIVEBORDER URGENCYBORDER
 %token GROUPBORDER UNGROUPBORDER
@@ -122,6 +122,20 @@ main : FONTNAME STRING {
  }
  conf->bwidth = $2;
  }
+ | HTILE NUMBER {
+ if ($2 < 0 || $2 > 99) {
+ yyerror("invalid htile percent");
+ YYERROR;
+ }
+ conf->htile = $2;
+ }
+ | VTILE NUMBER {
+ if ($2 < 0 || $2 > 99) {
+ yyerror("invalid vtile percent");
+ YYERROR;
+ }
+ conf->vtile = $2;
+ }
  | MOVEAMOUNT NUMBER {
  if ($2 < 0 || $2 > INT_MAX) {
  yyerror("invalid movemount");
@@ -316,6 +330,7 @@ lookup(char *s)
  { "fontname", FONTNAME},
  { "gap", GAP},
  { "groupborder", GROUPBORDER},
+ { "htile", HTILE},
  { "ignore", IGNORE},
  { "inactiveborder", INACTIVEBORDER},
  { "menubg", MENUBG},
@@ -329,6 +344,7 @@ lookup(char *s)
  { "unbind-mouse", UNBINDMOUSE},
  { "ungroupborder", UNGROUPBORDER},
  { "urgencyborder", URGENCYBORDER},
+ { "vtile", VTILE},
  { "wm", WM},
  { "yes", YES}
  };

Reply | Threaded
Open this post in threaded view
|

Re: PATCH: configurable tiling in cwm(1)

Okan Demirmen
On Fri 2020.03.27 at 00:30 +0000, Uwe Werler wrote:

> Hello @tech,
>
> with this diff https://marc.info/?l=openbsd-tech&m=149192690925713&w=2 the
> behaviour of cwm changed so vtile and htile always use 50% of the screen.
>
> This is a reasonable default but sometimes I want to have the master windows
> be bigger.
>
> Inspired by this patch https://marc.info/?l=openbsd-tech&m=154887686615696&w=2
> I suggest the following diff.
>
> This adds two new config options "htile percent" and "vtile percent" which
> define how much of the screen the current windows should occupy as the master
> window. If set to "0" then the old behaviour is restored where the current
> vertical or horizontal size of the window defines the size of the master
> window. If unset the current behaviour is unchaged that means the master
> windows uses half of the screen size.
>
> For example in .cwmrc:
>
> htile 66
> vtile 0
>
> For window-htile the master window will occupy 66% of the screen high or for
> window-vtile the current window width defines the screen width of the master
> window.
>
> Any thoughts?

I'm not a tiling user, but I have no real objection. Not a fan of the config
option, but I can't think of anything else off the top of my head. That said,
outside of a spacing fixes, I did re-word the cwmrc.5 bits as such (if it reads
well to other tile users):

     htile percent
             Set the percentage of screen the master window should occupy
             after calling window-htile.  If set to 0, the horizontal size of
             the master window will remain unchanged.  The default is 50.

     vtile percent
             Set the percentage of screen the master window should occupy
             after calling window-vtile.  If set to 0, the vertical size of
             the master window will remain unchanged.  The default is 50.


Index: calmwm.h
===================================================================
RCS file: /home/open/cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.374
diff -u -p -r1.374 calmwm.h
--- calmwm.h 24 Mar 2020 14:47:29 -0000 1.374
+++ calmwm.h 31 Mar 2020 12:04:21 -0000
@@ -291,6 +291,8 @@ struct conf {
  int bwidth;
  int mamount;
  int snapdist;
+ int htile;
+ int vtile;
  struct gap gap;
  char *color[CWM_COLOR_NITEMS];
  char *font;
Index: client.c
===================================================================
RCS file: /home/open/cvs/xenocara/app/cwm/client.c,v
retrieving revision 1.262
diff -u -p -r1.262 client.c
--- client.c 24 Mar 2020 14:47:29 -0000 1.262
+++ client.c 31 Mar 2020 12:05:51 -0000
@@ -940,7 +940,8 @@ 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;
+ if (Conf.htile > 0)
+ cc->geom.h = ((area.h - (cc->bwidth * 2)) * Conf.htile) / 100;
  client_resize(cc, 1);
  client_ptr_warp(cc);
 
@@ -1007,7 +1008,8 @@ 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;
+ if (Conf.vtile > 0)
+ cc->geom.w = ((area.w - (cc->bwidth * 2)) * Conf.vtile) / 100;
  cc->geom.h = area.h - (cc->bwidth * 2);
  client_resize(cc, 1);
  client_ptr_warp(cc);
Index: conf.c
===================================================================
RCS file: /home/open/cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.251
diff -u -p -r1.251 conf.c
--- conf.c 27 Feb 2020 14:56:39 -0000 1.251
+++ conf.c 31 Mar 2020 12:04:21 -0000
@@ -281,6 +281,8 @@ conf_init(struct conf *c)
  c->stickygroups = 0;
  c->bwidth = 1;
  c->mamount = 1;
+ c->htile = 50;
+ c->vtile = 50;
  c->snapdist = 0;
  c->ngroups = 0;
  c->nameqlen = 5;
Index: cwmrc.5
===================================================================
RCS file: /home/open/cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.75
diff -u -p -r1.75 cwmrc.5
--- cwmrc.5 13 Mar 2020 20:50:07 -0000 1.75
+++ cwmrc.5 31 Mar 2020 12:31:46 -0000
@@ -183,6 +183,13 @@ This
 can be used for applications such as
 .Xr xclock 1 ,
 where the user may wish to remain visible.
+.It Ic htile Ar percent
+Set the percentage of screen the master window should occupy
+after calling
+.Ic window-htile .
+If set to 0, the horizontal size of the master window will
+remain unchanged.
+The default is 50.
 .It Ic ignore Ar windowname
 Ignore, and do not warp to, windows with the name
 .Ar windowname
@@ -216,6 +223,13 @@ A special
 keyword
 .Dq all
 can be used to unbind all buttons.
+.It Ic vtile Ar percent
+Set the percentage of screen the master window should occupy
+after calling
+.Ic window-vtile .
+If set to 0, the vertical size of the master window will
+remain unchanged.
+The default is 50.
 .It Ic wm Ar name path
 Every
 .Ar name
@@ -303,11 +317,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 htile
+(default half) 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 vtile
+(default half) 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: /home/open/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 31 Mar 2020 12:04:21 -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 HTILE VTILE
 %token COLOR SNAPDIST
 %token ACTIVEBORDER INACTIVEBORDER URGENCYBORDER
 %token GROUPBORDER UNGROUPBORDER
@@ -122,6 +122,20 @@ main : FONTNAME STRING {
  }
  conf->bwidth = $2;
  }
+ | HTILE NUMBER {
+ if ($2 < 0 || $2 > 99) {
+ yyerror("invalid htile percent");
+ YYERROR;
+ }
+ conf->htile = $2;
+ }
+ | VTILE NUMBER {
+ if ($2 < 0 || $2 > 99) {
+ yyerror("invalid vtile percent");
+ YYERROR;
+ }
+ conf->vtile = $2;
+ }
  | MOVEAMOUNT NUMBER {
  if ($2 < 0 || $2 > INT_MAX) {
  yyerror("invalid movemount");
@@ -316,6 +330,7 @@ lookup(char *s)
  { "fontname", FONTNAME},
  { "gap", GAP},
  { "groupborder", GROUPBORDER},
+ { "htile", HTILE},
  { "ignore", IGNORE},
  { "inactiveborder", INACTIVEBORDER},
  { "menubg", MENUBG},
@@ -329,6 +344,7 @@ lookup(char *s)
  { "unbind-mouse", UNBINDMOUSE},
  { "ungroupborder", UNGROUPBORDER},
  { "urgencyborder", URGENCYBORDER},
+ { "vtile", VTILE},
  { "wm", WM},
  { "yes", YES}
  };