From: Matthias Kruk Date: Thu, 19 Mar 2020 16:43:31 +0000 (+0900) Subject: Add bookshelf and bookstack window layouts X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=4d50174538d7725f8e0ce6deb40417c5d8ab2aeb;p=dwm Add bookshelf and bookstack window layouts --- diff --git a/dwm.c b/dwm.c index e67c733..9f9ee2a 100755 --- a/dwm.c +++ b/dwm.c @@ -295,6 +295,8 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); static Atom getatomprop(Client *c, Atom prop); static unsigned int getsystraywidth(void); +static void bookshelf(Monitor*); +static void bookstack(Monitor*); /* variables */ static Systray *systray = NULL; @@ -1909,6 +1911,73 @@ tile(Monitor *m) { } } +static void bookshelf(Monitor *m) +{ + int n, w, x; + Client *c; + + /* count the clients on this monitor */ + for(n = 0, c = nexttiled(m->clients); c; + c = nexttiled(c->next), n++); + + if(!n) { + /* nothing to do */ + return; + } + + /* + * Start at x position m->wx, which is likely not going to be + * 0 in a multi-head setup. In other words, m->wx and m->wy + * are absolute coordinates on a virtual screen spanning all + * physical screens. This caused a bit of confusion since I + * first implemented this on a laptop and things broke when I + * plugged in a second screen at work. + */ + w = m->ww / n; + x = m->wx; + + /* assign positions and sizes to all clients on this screen */ + for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) { + resize(c, x, m->wy, w, m->wh, False); + + /* + * Since all clients are horizontally aligned and the + * same size, only the x coordinate changes. + */ + x += WIDTH(c); + } + + return; +} + +static void bookstack(Monitor *m) +{ + int n, h, y; + Client *c; + + /* + * The logic is essentially the same as in bookshelf(), though + * much more vertical, literally speaking. + */ + + for(n = 0, c = nexttiled(m->clients); c; + c = nexttiled(c->next), n++); + + if(!n) { + return; + } + + h = m->wh / n; + y = m->wy; + + for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) { + resize(c, m->wx, y, m->ww, h, False); + y += HEIGHT(c); + } + + return; +} + void togglebar(const Arg *arg) { selmon->showbar = !selmon->showbar;