From 23c5b2e81239675802d7cfe1b1572d89620f7485 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 16 Apr 2020 13:32:35 +0000 Subject: Allow configuring a percentage window size of the master window during htile/vtile actions. From Uwe Werler, with a few manpage tweaks. --- calmwm.h | 4 +++- client.c | 8 +++++--- conf.c | 4 +++- cwmrc.5 | 26 ++++++++++++++++++++++---- parse.y | 20 ++++++++++++++++++-- 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/calmwm.h b/calmwm.h index bd15a87..a0aeafa 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.374 2020/03/24 14:47:29 okan Exp $ + * $OpenBSD: calmwm.h,v 1.375 2020/04/16 13:32:35 okan Exp $ */ #ifndef _CALMWM_H_ @@ -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; diff --git a/client.c b/client.c index ffb1ed1..bea1dba 100644 --- a/client.c +++ b/client.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: client.c,v 1.262 2020/03/24 14:47:29 okan Exp $ + * $OpenBSD: client.c,v 1.263 2020/04/16 13:32:35 okan Exp $ */ #include @@ -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); diff --git a/conf.c b/conf.c index df6f56d..1e95bd9 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.251 2020/02/27 14:56:39 okan Exp $ + * $OpenBSD: conf.c,v 1.252 2020/04/16 13:32:35 okan Exp $ */ #include @@ -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; diff --git a/cwmrc.5 b/cwmrc.5 index a49ee35..bca861b 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.75 2020/03/13 20:50:07 tim Exp $ +.\" $OpenBSD: cwmrc.5,v 1.76 2020/04/16 13:32:35 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 13 2020 $ +.Dd $Mdocdate: April 16 2020 $ .Dt CWMRC 5 .Os .Sh NAME @@ -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 + border honored). 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. diff --git a/parse.y b/parse.y index ed8048a..c1bf8c5 100644 --- a/parse.y +++ b/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.72 2018/11/09 16:00:54 okan Exp $ */ +/* $OpenBSD: parse.y,v 1.73 2020/04/16 13:32:35 okan Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -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} }; -- cgit v1.2.3-2-gb3c3