# HG changeset patch # Parent d50470e24c51b93c44f02ea91fa31dd987e8b30f diff --git a/bstack.c b/bstack.c new file mode 100644 --- /dev/null +++ b/bstack.c @@ -0,0 +1,33 @@ +static void +bstack(Monitor *m) { + int w, h, mh, mx, tx, ty, tw; + unsigned int i, n; + Client *c; + + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + if(n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->wh : 0; + tw = m->ww / (n - m->nmaster); + ty = m->wy + mh; + } + else { + mh = m->wh; + tw = m->ww; + ty = m->wy; + } + for(i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if(i < m->nmaster) { + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), False); + mx += WIDTH(c); + } + else { + h = m->wh - mh; + resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), False); + if(tw != m->ww) + tx += WIDTH(c); + } + } +} diff --git a/bstackhoriz.c b/bstackhoriz.c new file mode 100644 --- /dev/null +++ b/bstackhoriz.c @@ -0,0 +1,31 @@ +static void +bstackhoriz(Monitor *m) { + int w, mh, mx, tx, ty, th; + unsigned int i, n; + Client *c; + + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + if(n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->wh : 0; + th = (m->wh - mh) / (n - m->nmaster); + ty = m->wy + mh; + } + else { + th = mh = m->wh; + ty = m->wy; + } + for(i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if(i < m->nmaster) { + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), False); + mx += WIDTH(c); + } + else { + resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), False); + if(th != m->wh) + ty += HEIGHT(c); + } + } +} diff --git a/config.def.h b/config.def.h --- a/config.def.h +++ b/config.def.h @@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ #include +#include "bstack.c" +#include "bstackhoriz.c" /* appearance */ static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-iso8859-1"; @@ -53,6 +55,8 @@ static const Bool resizehints = False; / static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ + { "===", bstackhoriz }, + { "TTT", bstack }, { "><>", NULL }, /* no layout function means floating behavior */ };