From c89cda27d36aaff8971905d067e4b89b6337259d Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 25 Aug 2022 16:21:52 +0200 Subject: stairs --- dwm.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'dwm.c') diff --git a/dwm.c b/dwm.c index 4bd377b..5867298 100644 --- a/dwm.c +++ b/dwm.c @@ -253,6 +253,7 @@ static void centeredmaster(Monitor *m); static void centeredfloatingmaster(Monitor *m); static void bstack(Monitor *m); static void bstackhoriz(Monitor *m); +static void stairs(Monitor *m); /* variables */ static const char broken[] = "broken"; @@ -1877,6 +1878,43 @@ spawn(const Arg *arg) } } +void +stairs(Monitor *m) +{ + unsigned int i, n, h, mw, my; + unsigned int ox, oy, ow, oh; /* stair offset values */ + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + if (n > m->nmaster) + mw = m->nmaster ? m->ww * m->mfact : 0; + else + mw = m->ww - m->gappx; + + for (i = 0, my = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; + resize(c, m->wx + m->gappx, m->wy + my, mw - (2 * c->bw) - m->gappx, h - (2 * c->bw), 0); + if (my + HEIGHT(c) + m->gappx < m->wh) + my += HEIGHT(c) + m->gappx; + } else { + oy = i - m->nmaster; + ox = stairdirection ? n - i - 1 : (stairsamesize ? i - m->nmaster : 0); + ow = stairsamesize ? n - m->nmaster - 1 : n - i - 1; + oh = stairsamesize ? ow : i - m->nmaster; + resize(c, + m->wx + mw + (ox * stairpx) + m->gappx, + m->wy + (oy * stairpx) + m->gappx, + m->ww - mw - (2 * c->bw) - (ow * stairpx) - (2 * m->gappx), + m->wh - (2 * c->bw) - (oh * stairpx) - (2 * m->gappx), + 0); + } + } +} + void tag(const Arg *arg) { -- cgit v1.2.3