[wiki] [sites] [dwm][patch] nrowgrid (grid layout with option to determine row count) || z0noxz
commit b55c00883798a7ed00d2a522a364e6c433134cc3
Author: z0noxz <chris_AT_noxz.tech>
Date: Mon Oct 1 13:04:08 2018 +0200
[dwm][patch] nrowgrid (grid layout with option to determine row count)
diff --git a/dwm.suckless.org/patches/nrowgrid/dwm-nrowgrid-6.1.diff b/dwm.suckless.org/patches/nrowgrid/dwm-nrowgrid-6.1.diff
new file mode 100644
index 00000000..e2e6505d
--- /dev/null
+++ b/dwm.suckless.org/patches/nrowgrid/dwm-nrowgrid-6.1.diff
_AT_@ -0,0 +1,77 @@
+Author: Chris Noxz <chris_AT_noxz.tech>
+
+diff -upN dwm-6.1/config.def.h dwm-nrowgrid-6.1/config.def.h
+--- dwm-6.1/config.def.h 2015-11-08 23:11:48.000000000 +0100
++++ dwm-nrowgrid-6.1/config.def.h 2018-10-01 10:44:05.631382842 +0200
+_AT_@ -34,11 +34,15 @@ static const float mfact = 0.55; /*
+ static const int nmaster = 1; /* number of clients in master area */
+ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
+
++#define FORCE_VSPLIT 1
++#include "nrowgrid.c"
++
+ static const Layout layouts[] = {
+ /* symbol arrange function */
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "###", nrowgrid },
+ };
+
+ /* key definitions */
+diff -upN dwm-6.1/nrowgrid.c dwm-nrowgrid-6.1/nrowgrid.c
+--- dwm-6.1/nrowgrid.c 1970-01-01 01:00:00.000000000 +0100
++++ dwm-nrowgrid-6.1/nrowgrid.c 2018-10-01 10:44:27.741263063 +0200
+_AT_@ -0,0 +1,52 @@
++void
++nrowgrid(Monitor *m)
++{
++ unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */
++ unsigned int cx, cy, cw, ch; /* client geometry */
++ unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */
++ unsigned int cols, rows = m->nmaster + 1;
++ Client *c;
++
++ /* count clients */
++ for (c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++
++ /* nothing to do here */
++ if (n == 0)
++ return;
++
++ /* force 2 clients to always split vertically */
++ if (FORCE_VSPLIT && n == 2)
++ rows = 1;
++
++ /* never allow empty rows */
++ if (n < rows)
++ rows = n;
++
++ /* define first row */
++ cols = n / rows;
++ uc = cols;
++ cy = m->wy;
++ ch = m->wh / rows;
++ uh = ch;
++
++ for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) {
++ if (ci == cols) {
++ uw = 0;
++ ci = 0;
++ ri++;
++
++ /* next row */
++ cols = (n - uc) / (rows - ri);
++ uc += cols;
++ cy = m->wy + uh;
++ ch = (m->wh - uh) / (rows - ri);
++ uh += ch;
++ }
++
++ cx = m->wx + uw;
++ cw = (m->ww - uw) / (cols - ci);
++ uw += cw;
++
++ resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, 0);
++ }
++}
diff --git a/dwm.suckless.org/patches/nrowgrid/index.md b/dwm.suckless.org/patches/nrowgrid/index.md
new file mode 100644
index 00000000..4570e1d9
--- /dev/null
+++ b/dwm.suckless.org/patches/nrowgrid/index.md
_AT_@ -0,0 +1,30 @@
+nrowgrid
+========
+
+Description
+-----------
+
+This grid layout gives you the option of determining the row count, which is
+set by `nmaster + 1`. So except for giving you a customizable grid, you also
+get the ability to show everything in one row, or in one column (`row = 1` and
+`row = client count`, respectively). When calculating the cell dimensions
+utilization trackers are used to make sure all pixels are utilized. The effect
+is that no overlays or no gaps are present, but on the other side all cells are
+not always of equal size.
+
+Example: splitting 2560 pixels into 6 cells gives you 2 cells with a width of
+426 pixels and 4 cells with a width of 427 pixels. No gaps, but not equal size,
+an off trade I believe many would be comfortable with.
+
+I personally want the presence of only 2 clients to always result in a vertical
+split. If you don't like this feature set the FORCE_VSPLIT to 0 in `config.h`.
+
+Download
+--------
+
+* [dwm-nrowgrid-6.1.diff](dwm-nrowgrid-6.1.diff)
+
+Authors
+-------
+
+* Chris Noxz - <chris_AT_noxz.tech>
Received on Mon Oct 01 2018 - 13:04:08 CEST
This archive was generated by hypermail 2.3.0
: Mon Oct 01 2018 - 13:12:26 CEST