dwl-patches/patches/mastercolumn/mastercolumn.patch
2024-07-13 14:02:39 -04:00

87 lines
2.7 KiB
Diff

From 64ef30f1970de25542dfcf1ed617d354558c69eb Mon Sep 17 00:00:00 2001
From: moe <moemmakki@gmail.com>
Date: Sat, 13 Jul 2024 13:02:34 -0400
Subject: [PATCH] init mastercolumn
---
config.def.h | 2 ++
dwl.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/config.def.h b/config.def.h
index 22d2171..68b27a7 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "||=", mastercol },
};
/* monitors */
@@ -139,6 +140,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_c, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index dc0437e..9e345d6 100644
--- a/dwl.c
+++ b/dwl.c
@@ -297,6 +297,7 @@ static int keyrepeat(void *data);
static void killclient(const Arg *arg);
static void locksession(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
+static void mastercol(Monitor *m);
static void maximizenotify(struct wl_listener *listener, void *data);
static void monocle(Monitor *m);
static void motionabsolute(struct wl_listener *listener, void *data);
@@ -1700,6 +1701,40 @@ unset_fullscreen:
}
}
+void
+mastercol(Monitor *m)
+{
+ unsigned int mw, mx, ty;
+ int i, n = 0;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+ n++;
+ if (n == 0)
+ return;
+
+ if (n > m->nmaster)
+ mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
+ else
+ mw = m->w.width;
+ i = mx = ty = 0;
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ if (i < m->nmaster) {
+ resize(c, (struct wlr_box){.x = m->w.x + mx, .y = m->w.y,
+ .width = (mw - mx) / (MIN(n, m->nmaster) - i), .height = m->w.height}, 0);
+ mx += c->geom.width;
+ } else {
+ resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
+ .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
+ ty += c->geom.height;
+ }
+ i++;
+ }
+}
+
void
maximizenotify(struct wl_listener *listener, void *data)
{
--
2.45.2