summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-01-27 03:46:21 -0500
committerMatt Hunter <m@lfurio.us>2026-01-18 00:18:46 -0500
commit597a5546cdb9ca912fa634776b3e873a80ccc277 (patch)
tree2bebe8895ef57c13805c1f1dd22e189426d7ad16
parent5e18bb5da386cd244f2f27e16b5e77ba5f66bfd9 (diff)
downloaddwm-597a5546cdb9ca912fa634776b3e873a80ccc277.tar.gz
dwm-597a5546cdb9ca912fa634776b3e873a80ccc277.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.
-rw-r--r--config.def.h2
-rw-r--r--dwm.c27
2 files changed, 29 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index 65b674f..c713ec1 100644
--- a/config.def.h
+++ b/config.def.h
@@ -46,6 +46,7 @@ static const Layout layouts[] = {
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "|M|", centeredmaster },
+ { "||=", col },
};
/* key definitions */
@@ -94,6 +95,7 @@ static const Key keys[] = {
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
diff --git a/dwm.c b/dwm.c
index ec9a8f9..6253c39 100644
--- a/dwm.c
+++ b/dwm.c
@@ -156,6 +156,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);
@@ -1763,6 +1764,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;