summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-03-02 20:01:00 -0500
committerMalfurious <m@lfurio.us>2024-03-05 21:04:47 -0500
commitfc3bd6f412c6bc21b68b997bd58f27ef5ee003ca (patch)
treec4f569936b8cbfdd892840fa386905d164a3b608 /dwm.c
parentec2fc9d5bd5de54ee8709c300c85c6cc591076a5 (diff)
downloaddwm-fc3bd6f412c6bc21b68b997bd58f27ef5ee003ca.tar.gz
dwm-fc3bd6f412c6bc21b68b997bd58f27ef5ee003ca.zip
patch: elit
elit is an inversion of the default tiling layout with the following characteristics: - master area is on the right - master windows are taken from the bottom of the stack (nmaster of them) - new clients spawn on the top of the stack and therefore appear at the top of the slave stacking area on the left - mfact controls the middle division point (motion is consistent with default layout) In effect, elit will keep specific client windows pinned in place on the right, allowing the use of a dynamic stack on the left. I've found this useful to use on a secondary monitor for opening and closing short-lived terminals without affecting the geometry of a web browser window, which can reserve the full height of the display.
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 1114e78..33f83cf 100644
--- a/dwm.c
+++ b/dwm.c
@@ -168,6 +168,7 @@ static void detachstack(Client *c);
static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m);
static void drawbars(void);
+static void elit(Monitor *m);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
@@ -835,6 +836,39 @@ drawbars(void)
}
void
+elit(Monitor *m)
+{
+ unsigned int i, n, h, mw, my, ty, nslave;
+ 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 * (1 - m->mfact) : 0;
+ nslave = n - m->nmaster;
+ } else {
+ mw = m->ww;
+ nslave = 0;
+ }
+
+ for (i = ty = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < nslave) {
+ h = (m->wh - ty) / (nslave - i);
+ resize(c, m->wx, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
+ if (ty + HEIGHT(c) < m->wh)
+ ty += HEIGHT(c);
+ } else {
+ h = (m->wh - my) / (n - i);
+ resize(c, m->wx + (m->ww - mw), m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
+ if (my + HEIGHT(c) < m->wh)
+ my += HEIGHT(c);
+ }
+ }
+}
+
+void
enternotify(XEvent *e)
{
Client *c;