diff --git a/patches/dwindle/README.md b/patches/dwindle/README.md new file mode 100644 index 0000000..946d5e9 --- /dev/null +++ b/patches/dwindle/README.md @@ -0,0 +1,55 @@ +### Description +Adds a dwindle (fibonacci-style) layout to dwl. +Windows are arranged by recursively splitting the remaining space, +alternating between horizontal and vertical splits + +With two windows: +``` +┌───────────────┬────────────────┐ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +└───────────────┴────────────────┘ +``` + +With three windows: +``` +┌───────────────┬────────────────┐ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +│ ├────────────────┤ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +└───────────────┴────────────────┘ +``` + +With four windows: +``` +┌───────────────┬────────────────┐ +│ │ │ +│ │ │ +│ │ │ +│ │ │ +│ ├───────┬────────┤ +│ │ │ │ +│ │ │ │ +│ │ │ │ +│ │ │ │ +└───────────────┴───────┴────────┘ +``` +### Download + +- [0.8](/dwl/dwl-patches/raw/branch/main/patches/dwindle/dwindle.patch) + +### Authors +[cana cronica](https://codeberg.org/cana) \ No newline at end of file diff --git a/patches/dwindle/dwindle.patch b/patches/dwindle/dwindle.patch new file mode 100644 index 0000000..caf5142 --- /dev/null +++ b/patches/dwindle/dwindle.patch @@ -0,0 +1,94 @@ +From e985b17e951f326e1459601cc39893609058c5ed Mon Sep 17 00:00:00 2001 +From: C4FE1 +Date: Fri, 20 Mar 2026 21:07:24 -0300 +Subject: [PATCH] dwl: add dwindle layout + +--- + config.def.h | 1 + + dwl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 52 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 8a6eda0..e1b823e 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -31,6 +31,7 @@ static const Rule rules[] = { + static const Layout layouts[] = { + /* symbol arrange function */ + { "[]=", tile }, ++ { "[\\]", dwindle }, + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, + }; +diff --git a/dwl.c b/dwl.c +index 101a45f..3b08073 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -335,6 +335,7 @@ static void startdrag(struct wl_listener *listener, void *data); + static void tag(const Arg *arg); + static void tagmon(const Arg *arg); + static void tile(Monitor *m); ++static void dwindle(Monitor *m); + static void togglefloating(const Arg *arg); + static void togglefullscreen(const Arg *arg); + static void toggletag(const Arg *arg); +@@ -2745,6 +2746,56 @@ tile(Monitor *m) + } + } + ++void ++dwindle(Monitor *m) ++{ ++ unsigned int i, n = 0; ++ Client *c; ++ ++ /* count clients */ ++ wl_list_for_each(c, &clients, link) ++ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) ++ n++; ++ ++ if (n == 0) ++ return; ++ ++ int nx = m->w.x; ++ int ny = m->w.y; ++ int nw = m->w.width; ++ int nh = m->w.height; ++ ++ int horizontal = 1; // toggle split direction ++ i = 0; ++ ++ wl_list_for_each(c, &clients, link) { ++ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) ++ continue; ++ ++ if (i == n - 1) { ++ /* last window gets remaining space */ ++ resize(c, (struct wlr_box){nx, ny, nw, nh}, 0); ++ } else if (horizontal) { ++ int w = nw / 2; ++ ++ resize(c, (struct wlr_box){nx, ny, w, nh}, 0); ++ ++ nx += w; ++ nw -= w; ++ } else { ++ int h = nh / 2; ++ ++ resize(c, (struct wlr_box){nx, ny, nw, h}, 0); ++ ++ ny += h; ++ nh -= h; ++ } ++ ++ horizontal = !horizontal; ++ i++; ++ } ++} ++ + void + togglefloating(const Arg *arg) + { +-- +2.53.0 +