summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-01-27 03:46:21 -0500
committerMalfurious <m@lfurio.us>2023-06-03 21:58:14 -0400
commita70fd955bacbc6465d1ed7d523477f0cd4725ab7 (patch)
tree0988fc544fc1605a2d09e8a25ea51121d0f87228 /dwm.c
parentb23a9c430b4c8af2b71a2bd6c7cd74f550ef42e6 (diff)
downloaddwm-a70fd955bacbc6465d1ed7d523477f0cd4725ab7.tar.gz
dwm-a70fd955bacbc6465d1ed7d523477f0cd4725ab7.zip
patch: columns
This patch adds an extra layout to dwm called col in which the windows in the master area are arranged in colums of equal size. The number of columns is always nmaster + 1, and the last column is a stack of leftover windows just like the normal tile layout. It effectively acts like the default tiling mode, except provides for vertical instead of horizontal master windows.
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 3219c52..e7077a7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -155,6 +155,7 @@ static void checkotherwm(void);
static void cleanup(void);
static void cleanupmon(Monitor *mon);
static void clientmessage(XEvent *e);
+static void col(Monitor *);
static void configure(Client *c);
static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e);
@@ -1693,6 +1694,32 @@ tagmon(const Arg *arg)
}
void
+col(Monitor *m)
+{
+ unsigned int i, n, h, w, x, y, mw;
+ 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;
+ for (i = x = y = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ w = (mw - x) / (MIN(n, m->nmaster) - i);
+ resize(c, x + m->wx, m->wy, w - (2 * c->bw), m->wh - (2 * c->bw), 0);
+ x += WIDTH(c);
+ } else {
+ h = (m->wh - y) / (n - i);
+ resize(c, x + m->wx, m->wy + y, m->ww - x - (2 * c->bw), h - (2 * c->bw), 0);
+ y += HEIGHT(c);
+ }
+}
+
+void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;