summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-09-09 19:31:16 +0200
committerbakkeby <[email protected]>2019-09-09 19:31:16 +0200
commit342fc03b885413510257cfbfeef5c0e2eb6691fb (patch)
tree5960524847204b9eb4c959b8e46efd7056f6b777 /patch
parent9081aef7485d4d201ff0531e913702586e04929e (diff)
downloaddwm-flexipatch-342fc03b885413510257cfbfeef5c0e2eb6691fb.tar.gz
dwm-flexipatch-342fc03b885413510257cfbfeef5c0e2eb6691fb.zip
Adding horizgrid and gridmode layouts
Diffstat (limited to 'patch')
-rw-r--r--patch/grid.c50
-rw-r--r--patch/grid.h1
-rw-r--r--patch/horizgrid.c82
-rw-r--r--patch/horizgrid.h1
-rw-r--r--patch/include.c8
-rw-r--r--patch/include.h8
6 files changed, 150 insertions, 0 deletions
diff --git a/patch/grid.c b/patch/grid.c
new file mode 100644
index 0000000..34f187e
--- /dev/null
+++ b/patch/grid.c
@@ -0,0 +1,50 @@
+#if VANITYGAPS_PATCH
+static void
+grid(Monitor *m)
+{
+ unsigned int i, n, cx, cy, cw, ch, cols, rows;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ /* grid dimensions */
+ for (rows = 0; rows <= n/2; rows++)
+ if (rows*rows >= n)
+ break;
+ cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
+
+ /* window geoms (cell height/width) */
+ ch = (m->wh - 2*oh - ih * (rows - 1)) / (rows ? rows : 1);
+ cw = (m->ww - 2*ov - iv * (cols - 1)) / (cols ? cols : 1);
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ cx = m->wx + (i / rows) * (cw + iv) + ov;
+ cy = m->wy + (i % rows) * (ch + ih) + oh;
+ resize(c, cx, cy, cw - 2*c->bw, ch - 2*c->bw, False);
+ }
+}
+#else
+static void
+grid(Monitor *m)
+{
+ unsigned int i, n, cx, cy, cw, ch, cols, rows;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+
+ /* grid dimensions */
+ for (rows = 0; rows <= n/2; rows++)
+ if (rows*rows >= n)
+ break;
+ cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
+
+ /* window geoms (cell height/width) */
+ ch = m->wh / (rows ? rows : 1);
+ cw = m->ww / (cols ? cols : 1);
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ cx = m->wx + (i / rows) * cw;
+ cy = m->wy + (i % rows) * ch;
+ resize(c, cx, cy, cw - 2*c->bw, ch - 2*c->bw, False);
+ }
+}
+#endif \ No newline at end of file
diff --git a/patch/grid.h b/patch/grid.h
new file mode 100644
index 0000000..81149ce
--- /dev/null
+++ b/patch/grid.h
@@ -0,0 +1 @@
+static void grid(Monitor *m); \ No newline at end of file
diff --git a/patch/horizgrid.c b/patch/horizgrid.c
new file mode 100644
index 0000000..60eea1c
--- /dev/null
+++ b/patch/horizgrid.c
@@ -0,0 +1,82 @@
+#if VANITYGAPS_PATCH
+void
+horizgrid(Monitor *m) {
+ Client *c;
+ unsigned int n, i;
+ int w = 0, oh, ov, ih, iv;
+ int ntop, nbottom = 0;
+
+ /* Count windows */
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ if (n == 1) { /* Just fill the whole screen */
+ c = nexttiled(m->clients);
+ resize(c, m->wx + ov, m->wy + oh, m->ww - 2*ov - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
+ } else if (n == 2) { /* Split vertically */
+ w = (m->ww - 2*ov - iv) / 2;
+ c = nexttiled(m->clients);
+ resize(c, m->wx + ov, m->wy + oh, w - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
+ c = nexttiled(c->next);
+ resize(c, m->wx + ov + w + iv, m->wy + oh, w - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
+ } else {
+ ntop = n / 2;
+ nbottom = n - ntop;
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < ntop)
+ resize(
+ c,
+ m->wx + ov + i * ((m->ww - 2*ov - iv*(ntop - 1)) / ntop + iv),
+ m->wy + oh,
+ (m->ww - 2*ov - iv*(ntop - 1)) / ntop - (2*c->bw),
+ (m->wh - 2*oh - ih) / 2 - (2*c->bw),
+ False
+ );
+ else
+ resize(
+ c,
+ m->wx + ov + (i - ntop) * ((m->ww - 2*ov - iv*(nbottom - 1)) / nbottom + iv),
+ m->wy + oh + ih + (m->wh - 2*oh - ih) / 2,
+ (m->ww - 2*ov - iv*(nbottom - 1)) / nbottom - (2*c->bw),
+ (m->wh - 2*oh - ih) / 2 - (2*c->bw),
+ False
+ );
+ }
+ }
+}
+#else
+void
+horizgrid(Monitor *m) {
+ Client *c;
+ unsigned int n, i;
+ int w = 0;
+ int ntop, nbottom = 0;
+
+ /* Count windows */
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+
+ if(n == 0)
+ return;
+ else if(n == 1) { /* Just fill the whole screen */
+ c = nexttiled(m->clients);
+ resize(c, m->wx, m->wy, m->ww - (2*c->bw), m->wh - (2*c->bw), False);
+ } else if(n == 2) { /* Split vertically */
+ w = m->ww / 2;
+ c = nexttiled(m->clients);
+ resize(c, m->wx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
+ c = nexttiled(c->next);
+ resize(c, m->wx + w, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
+ } else {
+ ntop = n / 2;
+ nbottom = n - ntop;
+ for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if(i < ntop)
+ resize(c, m->wx + i * m->ww / ntop, m->wy, m->ww / ntop - (2*c->bw), m->wh / 2 - (2*c->bw), False);
+ else
+ resize(c, m->wx + (i - ntop) * m->ww / nbottom, m->wy + m->wh / 2, m->ww / nbottom - (2*c->bw), m->wh / 2 - (2*c->bw), False);
+ }
+ }
+}
+#endif \ No newline at end of file
diff --git a/patch/horizgrid.h b/patch/horizgrid.h
new file mode 100644
index 0000000..71a57fb
--- /dev/null
+++ b/patch/horizgrid.h
@@ -0,0 +1 @@
+static void horizgrid(Monitor *m); \ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index 79b9eb6..3eb8ae9 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -74,6 +74,14 @@
#include "gapplessgrid.c"
#endif
+#if GRIDMODE_LAYOUT
+#include "grid.c"
+#endif
+
+#if HORIZGRID_LAYOUT
+#include "horizgrid.c"
+#endif
+
#if MONOCLE_LAYOUT
#include "monocle.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index caa6190..a5bafa6 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -70,6 +70,14 @@
#include "gapplessgrid.h"
#endif
+#if GRIDMODE_LAYOUT
+#include "grid.h"
+#endif
+
+#if HORIZGRID_LAYOUT
+#include "horizgrid.h"
+#endif
+
#if MONOCLE_LAYOUT
#include "monocle.h"
#endif