diff options
author | Bryson Steck <brysonsteck@protonmail.com> | 2022-11-12 18:05:21 -0700 |
---|---|---|
committer | Bryson Steck <brysonsteck@protonmail.com> | 2022-11-12 18:05:21 -0700 |
commit | 7516b03d7d3c7844ebdab69cf731d59ea2b3c84d (patch) | |
tree | 4c380f744f1c389ddc030a377332e4b4cbb0b816 /dwm.c | |
parent | 4da4ae80e489b477ec9913317a209f9ad8f9256a (diff) | |
download | dwm-7516b03d7d3c7844ebdab69cf731d59ea2b3c84d.tar dwm-7516b03d7d3c7844ebdab69cf731d59ea2b3c84d.tar.gz dwm-7516b03d7d3c7844ebdab69cf731d59ea2b3c84d.tar.bz2 |
add bstack and fixed config format
Diffstat (limited to 'dwm.c')
-rw-r--r-- | dwm.c | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -237,6 +237,8 @@ static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); +static void bstack(Monitor *m); +static void bstackhoriz(Monitor *m); /* variables */ static const char broken[] = "broken"; @@ -2185,3 +2187,65 @@ main(int argc, char *argv[]) return EXIT_SUCCESS; } + +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), 0); + mx += WIDTH(c); + } else { + h = m->wh - mh; + resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0); + if (tw != m->ww) + tx += WIDTH(c); + } + } +} + +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), 0); + mx += WIDTH(c); + } else { + resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0); + if (th != m->wh) + ty += HEIGHT(c); + } + } +} |