summaryrefslogtreecommitdiffstats
path: root/dwl-patches/patches/gaplessgrid/gaplessgrid-20230801.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dwl-patches/patches/gaplessgrid/gaplessgrid-20230801.patch')
-rw-r--r--dwl-patches/patches/gaplessgrid/gaplessgrid-20230801.patch97
1 files changed, 97 insertions, 0 deletions
diff --git a/dwl-patches/patches/gaplessgrid/gaplessgrid-20230801.patch b/dwl-patches/patches/gaplessgrid/gaplessgrid-20230801.patch
new file mode 100644
index 0000000..2ade7da
--- /dev/null
+++ b/dwl-patches/patches/gaplessgrid/gaplessgrid-20230801.patch
@@ -0,0 +1,97 @@
+From 958cf2c2415927e2f7b471da9ada7c6e7d169a63 Mon Sep 17 00:00:00 2001
+From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com>
+Date: Mon, 8 Jan 2024 16:11:30 +0100
+Subject: [PATCH] revive gaplessgrid
+
+---
+ config.def.h | 2 ++
+ dwl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 48 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index a8ed61d..7400b7f 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 */
+@@ -134,6 +135,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 632dabf..4d810f7 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -268,6 +268,7 @@ static void focusclient(Client *c, int lift);
+ static void focusmon(const Arg *arg);
+ static void focusstack(const Arg *arg);
+ static Client *focustop(Monitor *m);
++static void gaplessgrid(Monitor *m);
+ static void fullscreennotify(struct wl_listener *listener, void *data);
+ static void handlesig(int signo);
+ static void incnmaster(const Arg *arg);
+@@ -1311,6 +1312,51 @@ handlesig(int signo)
+ }
+ }
+
++void
++gaplessgrid(Monitor *m)
++{
++ unsigned 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;
++ 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.43.0
+