From 34d7666c923560b707def6e359efd49587de3fd5 Mon Sep 17 00:00:00 2001 From: DanielMowitz Date: Wed, 6 Oct 2021 18:59:55 +0200 Subject: [PATCH] Add bottomstack patch. Authors * Anselm R Garbe - anselm@garbe.us * Laslo Hunhold - dev@frign.de (6.1, git ports) Edited for dwl by * Daniel Mowitz - git.daniel@mowitz.rocks --- config.def.h | 4 + config.def.h.orig | 116 ++ dwl.c | 83 ++ dwl.c.orig | 2608 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2811 insertions(+) create mode 100644 config.def.h.orig create mode 100644 dwl.c.orig diff --git a/config.def.h b/config.def.h index 089aa379..8e20ecb1 100644 --- a/config.def.h +++ b/config.def.h @@ -22,6 +22,8 @@ static const Layout layouts[] = { { "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "TTT", bstack }, + { "===", bstackhoriz }, }; /* monitors @@ -82,6 +84,8 @@ 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, XKB_KEY_u, setlayout, {.v = &layouts[3]} }, + { MODKEY, XKB_KEY_o, setlayout, {.v = &layouts[4]} }, { MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, diff --git a/dwl.c b/dwl.c index 6303c25f..3e611cb6 100644 --- a/dwl.c +++ b/dwl.c @@ -301,6 +301,8 @@ static struct wlr_surface *xytolayersurface(struct wl_list *layer_surfaces, double x, double y, double *sx, double *sy); static Monitor *xytomon(double x, double y); static void zoom(const Arg *arg); +static void bstack(Monitor *m); +static void bstackhoriz(Monitor *m); /* variables */ static const char broken[] = "broken"; @@ -2606,3 +2608,84 @@ main(int argc, char *argv[]) usage: BARF("Usage: %s [-s startup command]", argv[0]); } + +static void +bstack(Monitor *m) +{ + int w, h, mh, mx, tx, ty, tw; + unsigned int i, n = 0; + Client *c; + + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating) + n++; + if (n == 0) + return; + + if (n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->w.height : 0; + tw = m->w.width / (n - m->nmaster); + ty = m->w.y + mh; + } else { + mh = m->w.height; + tw = m->w.width; + ty = m->w.y; + } + + i = mx = 0; + tx = m-> w.x; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c, m) || c->isfloating) + continue; + if (i < m->nmaster) { + w = (m->w.width - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->w.x + mx, m->w.y, w - (2 * c->bw), mh - (2 * c->bw), 0); + mx += c->geom.width; + } else { + h = m->w.height - mh; + resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0); + if (tw != m->w.width) + tx += c->geom.width; + } + i++; + } +} + +static void +bstackhoriz(Monitor *m) { + int w, mh, mx, tx, ty, th; + unsigned int i, n = 0; + Client *c; + + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating) + n ++; + if (n == 0) + return; + + if (n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->w.height : 0; + th = (m->w.height - mh) / (n - m->nmaster); + ty = m->w.y + mh; + } else { + th = mh = m->w.height; + ty = m->w.y; + } + + i = mx = 0; + tx = m-> w.x; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c,m) || c->isfloating) + continue; + if (i < m->nmaster) { + w = (m->w.width - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->w.x + mx, m->w.y, w - (2 * c->bw), mh - (2 * c->bw), 0); + mx += c->geom.width; + } else { + resize(c, tx, ty, m->w.width - (2 * c->bw), th - (2 * c->bw), 0); + if (th != m->w.height) + ty += c->geom.height; + } + i++; + } +}