diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2021-08-15 20:51:46 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2021-08-15 20:51:46 -0400 |
commit | 44ddcd688c9f873ec9c04ea66139ff19871ba386 (patch) | |
tree | 01305a4825a026ab86e53416b84bc9cb2e9b5439 | |
parent | 1183a319a02cf89aa7311124fca7f15332c80547 (diff) |
Create vertile layoutvertile
This layout is an alternative to the tile layout optimized for wide
vertical monitors. As such, the master stack is above the tiled stack
and takes the full width of the monitor. The following shows the layout
with a master stack (of a single client) followed by three tiled
clients.
|---------------------------|
| |
| |
| M |
| |
| |
|---------------------------|
| t1 |
|---------------------------|
| t2 |
|---------------------------|
| t3 |
|---------------------------|
-rw-r--r-- | config.def.h | 2 | ||||
-rw-r--r-- | dwl.c | 35 |
2 files changed, 37 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 089aa37..2a955d6 100644 --- a/config.def.h +++ b/config.def.h @@ -22,6 +22,7 @@ static const Layout layouts[] = { { "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "|v|", vertile }, }; /* monitors @@ -82,6 +83,7 @@ static const Key keys[] = { { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_T, setlayout, {.v = &layouts[3]} }, { MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, @@ -284,6 +284,7 @@ static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); +static void vertile(Monitor *m); static void togglefloating(const Arg *arg); static void togglefullscreen(const Arg *arg); static void toggletag(const Arg *arg); @@ -2232,6 +2233,40 @@ tile(Monitor *m) } void +vertile(Monitor *m) +{ + unsigned int i, n = 0, h, mh, my, ty; + Client *c; + + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating) + n++; + if (n == 0) + return; + + if (n > m->nmaster) + ty = mh = m->nmaster ? m->w.height * m->mfact : 0; + else + ty = mh = m->w.height; + i = my = 0; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) + continue; + if (i < m->nmaster) { + h = ( mh - my ) / (MIN(n, m->nmaster) - i); + resize(c, m->w.x, m->w.y + my, m->w.width, h, 0); + my += c->geom.height; + } else { + h = ( m->w.height - ty ) / (n - i); + resize(c, m->w.x, m->w.y + ty, m->w.width, h, 0); + ty += c->geom.height; + } + i++; + } +} + + +void togglefloating(const Arg *arg) { Client *sel = selclient(); |