From 6dde2a3b65d48ca2bf1919d56cbd5898e05757ae Mon Sep 17 00:00:00 2001 From: nate zhou Date: Sun, 8 Mar 2026 11:42:29 +0800 Subject: [PATCH] gaplessgrid: update for 0.8 --- patches/gaplessgrid/README.md | 3 +- .../gaplessgrid/gaplessgrid-20251031.patch | 102 ++++++++++++++++++ patches/gaplessgrid/gaplessgrid.patch | 32 +++--- 3 files changed, 120 insertions(+), 17 deletions(-) create mode 100644 patches/gaplessgrid/gaplessgrid-20251031.patch diff --git a/patches/gaplessgrid/README.md b/patches/gaplessgrid/README.md index b0354de..b22ead8 100644 --- a/patches/gaplessgrid/README.md +++ b/patches/gaplessgrid/README.md @@ -4,7 +4,8 @@ Arranges windows in a grid. Except it adjusts the number of windows in the first On widescreens (w > 2*h), it splits to three columns before splitting rows. ### Download -- [2025-10-31](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid.patch) +- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid.patch) +- [2025-10-31](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20251031.patch) - [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240918.patch) - [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240714.patch) - [2023-08-01](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20230801.patch) diff --git a/patches/gaplessgrid/gaplessgrid-20251031.patch b/patches/gaplessgrid/gaplessgrid-20251031.patch new file mode 100644 index 0000000..f54e1d1 --- /dev/null +++ b/patches/gaplessgrid/gaplessgrid-20251031.patch @@ -0,0 +1,102 @@ +From 38427b81367e8b4d2aad708a1d463bc793aac65e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= +Date: Fri, 31 Oct 2025 15:46:48 -0300 +Subject: [PATCH] take on gaplessgrid and fix minor indentation and typos + +--- + config.def.h | 2 ++ + dwl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 53 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 95c2afa..2054107 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 }, ++ { "###", gaplessgrid }, + }; + + /* 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_g, 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 12f441e..7ab5323 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -288,6 +288,7 @@ static void focusstack(const Arg *arg); + static Client *focustop(Monitor *m); + static void fullscreennotify(struct wl_listener *listener, void *data); + static void gpureset(struct wl_listener *listener, void *data); ++static void gaplessgrid(Monitor *m); + static void handlesig(int signo); + static void incnmaster(const Arg *arg); + static void inputdevice(struct wl_listener *listener, void *data); +@@ -1566,6 +1567,56 @@ handlesig(int signo) + quit(NULL); + } + ++void ++gaplessgrid(Monitor *m) ++{ ++ int n = 0, i = 0, ch, cw, cn, rn, rows, cols; ++ Client *c; ++ ++ wl_list_for_each(c, &clients, link) ++ if (VISIBLEON(c, m) && !c->isfloating) ++ n++; ++ if (n == 0) ++ return; ++ ++ /* grid dimensions */ ++ for (cols = 0; cols <= (n / 2); cols++) ++ if ((cols * cols) >= n) ++ break; ++ ++ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ ++ cols = 2; ++ ++ /* widescreen is better if 3 columns */ ++ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1) ++ cols = 3; ++ ++ rows = n / cols; ++ ++ /* window geometries */ ++ cw = cols ? m->w.width / cols : m->w.width; ++ cn = 0; /* current column number */ ++ rn = 0; /* current row number */ ++ wl_list_for_each(c, &clients, link) { ++ unsigned int cx, cy; ++ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) ++ continue; ++ ++ if ((i / rows + 1) > (cols - n % cols)) ++ rows = n / cols + 1; ++ ch = rows ? m->w.height / rows : m->w.height; ++ cx = m->w.x + cn * cw; ++ cy = m->w.y + rn * ch; ++ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0); ++ rn++; ++ if (rn >= rows) { ++ rn = 0; ++ cn++; ++ } ++ i++; ++ } ++} ++ + void + incnmaster(const Arg *arg) + { +-- +2.51.0 + diff --git a/patches/gaplessgrid/gaplessgrid.patch b/patches/gaplessgrid/gaplessgrid.patch index f54e1d1..d869928 100644 --- a/patches/gaplessgrid/gaplessgrid.patch +++ b/patches/gaplessgrid/gaplessgrid.patch @@ -1,7 +1,7 @@ -From 38427b81367e8b4d2aad708a1d463bc793aac65e Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= -Date: Fri, 31 Oct 2025 15:46:48 -0300 -Subject: [PATCH] take on gaplessgrid and fix minor indentation and typos +From 91d34b1c664fe273a82eb7ff01e92b828feab5a9 Mon Sep 17 00:00:00 2001 +From: nate zhou +Date: Sat, 28 Feb 2026 21:42:04 +0800 +Subject: [PATCH] Patch: gaplessgrid.patch --- config.def.h | 2 ++ @@ -9,10 +9,10 @@ Subject: [PATCH] take on gaplessgrid and fix minor indentation and typos 2 files changed, 53 insertions(+) diff --git a/config.def.h b/config.def.h -index 95c2afa..2054107 100644 +index 8a6eda0..8cb1782 100644 --- a/config.def.h +++ b/config.def.h -@@ -34,6 +34,7 @@ static const Layout layouts[] = { +@@ -33,6 +33,7 @@ static const Layout layouts[] = { { "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, @@ -20,16 +20,16 @@ index 95c2afa..2054107 100644 }; /* 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_g, 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} }, +@@ -135,6 +136,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_g, 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 12f441e..7ab5323 100644 +index 44f3ad9..83c053f 100644 --- a/dwl.c +++ b/dwl.c @@ -288,6 +288,7 @@ static void focusstack(const Arg *arg); @@ -98,5 +98,5 @@ index 12f441e..7ab5323 100644 incnmaster(const Arg *arg) { -- -2.51.0 +2.53.0