summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-09-09 00:18:47 +0200
committerbakkeby <[email protected]>2019-09-09 00:18:47 +0200
commite490af0eb2d24e94af67c934e6ae05246ee7c885 (patch)
tree7784227501f1bc5f20a308cafcd6573450413cd5 /patch
parent747512af21fabae327a1a4e7b01bfd00af8eeb15 (diff)
downloaddwm-flexipatch-e490af0eb2d24e94af67c934e6ae05246ee7c885.tar.gz
dwm-flexipatch-e490af0eb2d24e94af67c934e6ae05246ee7c885.zip
Adding cfacts, vanitygaps patches and bottomstack layouts
Diffstat (limited to 'patch')
-rw-r--r--patch/bstack.c152
-rw-r--r--patch/bstack.h1
-rw-r--r--patch/bstackhoriz.c155
-rw-r--r--patch/bstackhoriz.h1
-rw-r--r--patch/cfacts.c17
-rw-r--r--patch/cfacts.h1
-rw-r--r--patch/include.c30
-rw-r--r--patch/include.h28
-rw-r--r--patch/monocle.c14
-rw-r--r--patch/monocle.h1
-rw-r--r--patch/tile.c140
-rw-r--r--patch/tile.h1
-rw-r--r--patch/vanitygaps.c143
-rw-r--r--patch/vanitygaps.h18
14 files changed, 701 insertions, 1 deletions
diff --git a/patch/bstack.c b/patch/bstack.c
new file mode 100644
index 0000000..d202e06
--- /dev/null
+++ b/patch/bstack.c
@@ -0,0 +1,152 @@
+#if VANITYGAPS_PATCH && CFACTS_PATCH
+static void
+bstack(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ float mfacts, sfacts;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n, &mfacts, &sfacts);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh;
+ sw = mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1);
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = (mh - ih) * (1 - m->mfact);
+ mh = (mh - ih) * m->mfact;
+ sx = mx;
+ sy = my + mh + ih;
+ sw = m->ww - 2*ov - iv * (n - m->nmaster - 1);
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw * (c->cfact / mfacts) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c) + iv;
+ } else {
+ resize(c, sx, sy, sw * (c->cfact / sfacts) - (2*c->bw), sh - (2*c->bw), 0);
+ sx += WIDTH(c) + iv;
+ }
+ }
+}
+#elif VANITYGAPS_PATCH
+static void
+bstack(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh;
+ sw = mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1);
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = (mh - ih) * (1 - m->mfact);
+ mh = (mh - ih) * m->mfact;
+ sy = my + mh + ih;
+ sw = m->ww - 2*ov - iv * (n - m->nmaster - 1);
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c) + iv;
+ } else {
+ resize(c, sx, sy, sw / (n - MIN(n, m->nmaster)) - (2*c->bw), sh - (2*c->bw), 0);
+ sx += WIDTH(c) + iv;
+ }
+ }
+}
+#elif CFACTS_PATCH
+static void
+bstack(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ float mfacts = 1, sfacts = 1;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
+ if (n < m->nmaster)
+ mfacts += c->cfact;
+ else
+ sfacts += c->cfact;
+ }
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx;
+ sy = my = m->wy;
+ sh = mh = m->wh;
+ sw = mw = m->ww;
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = mh * (1 - m->mfact);
+ mh = mh * m->mfact;
+ sy = my + mh;
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw * (c->cfact / mfacts) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ resize(c, sx, sy, sw * (c->cfact / sfacts) - (2*c->bw), sh - (2*c->bw), 0);
+ sx += WIDTH(c);
+ }
+ }
+}
+#else
+static void
+bstack(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx;
+ sy = my = m->wy;
+ sh = mh = m->wh;
+ sw = mw = m->ww;
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = mh * (1 - m->mfact);
+ mh = mh * m->mfact;
+ sy = my + mh;
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ resize(c, sx, sy, sw / (n - MIN(n, m->nmaster)) - (2*c->bw), sh - (2*c->bw), 0);
+ sx += WIDTH(c);
+ }
+ }
+}
+#endif \ No newline at end of file
diff --git a/patch/bstack.h b/patch/bstack.h
new file mode 100644
index 0000000..56c99ff
--- /dev/null
+++ b/patch/bstack.h
@@ -0,0 +1 @@
+static void bstack(Monitor *m); \ No newline at end of file
diff --git a/patch/bstackhoriz.c b/patch/bstackhoriz.c
new file mode 100644
index 0000000..3a4d11a
--- /dev/null
+++ b/patch/bstackhoriz.c
@@ -0,0 +1,155 @@
+#if VANITYGAPS_PATCH && CFACTS_PATCH
+static void
+bstackhoriz(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ float mfacts, sfacts;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n, &mfacts, &sfacts);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh;
+ sw = mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1);
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = (mh - ih) * (1 - m->mfact);
+ mh = (mh - ih) * m->mfact;
+ sy = my + mh + ih;
+ sh = m->wh - mh - 2*oh - ih * (n - m->nmaster);
+ sw = m->ww - 2*ov;
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw * (c->cfact / mfacts) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c) + iv;
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh * (c->cfact / sfacts) - (2*c->bw), 0);
+ sy += HEIGHT(c) + ih;
+ }
+ }
+}
+#elif VANITYGAPS_PATCH
+static void
+bstackhoriz(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh;
+ sw = mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1);
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = (mh - ih) * (1 - m->mfact);
+ mh = (mh - ih) * m->mfact;
+ sy = my + mh + ih;
+ sh = m->wh - mh - 2*oh - ih * (n - m->nmaster);
+ sw = m->ww - 2*ov;
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c) + iv;
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh / (n - MIN(n, m->nmaster)) - (2*c->bw), 0);
+ sy += HEIGHT(c) + ih;
+ }
+ }
+}
+#elif CFACTS_PATCH
+static void
+bstackhoriz(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ float mfacts = 1, sfacts = 1;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
+ if (n < m->nmaster)
+ mfacts += c->cfact;
+ else
+ sfacts += c->cfact;
+ }
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx;
+ sy = my = m->wy;
+ sh = mh = m->wh;
+ sw = mw = m->ww;
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = mh * (1 - m->mfact);
+ mh = mh * m->mfact;
+ sy = my + mh;
+ sh = m->wh - mh;
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw * (c->cfact / mfacts) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh * (c->cfact / sfacts) - (2*c->bw), 0);
+ sy += HEIGHT(c);
+ }
+ }
+}
+#else
+static void
+bstackhoriz(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx;
+ sy = my = m->wy;
+ sh = mh = m->wh;
+ sw = mw = m->ww;
+
+ if (m->nmaster && n > m->nmaster) {
+ sh = mh * (1 - m->mfact);
+ mh = mh * m->mfact;
+ sy = my + mh;
+ sh = m->wh - mh;
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh / (n - MIN(n, m->nmaster)) - (2*c->bw), 0);
+ sy += HEIGHT(c);
+ }
+ }
+}
+#endif \ No newline at end of file
diff --git a/patch/bstackhoriz.h b/patch/bstackhoriz.h
new file mode 100644
index 0000000..8dd0ebd
--- /dev/null
+++ b/patch/bstackhoriz.h
@@ -0,0 +1 @@
+static void bstackhoriz(Monitor *m); \ No newline at end of file
diff --git a/patch/cfacts.c b/patch/cfacts.c
new file mode 100644
index 0000000..085071f
--- /dev/null
+++ b/patch/cfacts.c
@@ -0,0 +1,17 @@
+void
+setcfact(const Arg *arg) {
+ float f;
+ Client *c;
+
+ c = selmon->sel;
+
+ if (!arg || !c || !selmon->lt[selmon->sellt]->arrange)
+ return;
+ f = arg->f + c->cfact;
+ if (arg->f == 0.0)
+ f = 1.0;
+ else if (f < 0.25 || f > 4.0)
+ return;
+ c->cfact = f;
+ arrange(selmon);
+} \ No newline at end of file
diff --git a/patch/cfacts.h b/patch/cfacts.h
new file mode 100644
index 0000000..b8d8b04
--- /dev/null
+++ b/patch/cfacts.h
@@ -0,0 +1 @@
+static void setcfact(const Arg *arg); \ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index b5cf100..b333fbc 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -1,3 +1,5 @@
+/* Patches */
+
#if ALPHA_PATCH
#include "alpha.c"
#endif
@@ -10,9 +12,13 @@
#include "autostart.c"
#endif
+#if CFACTS_PATCH
+#include "cfacts.c"
+#endif
+
#if CYCLELAYOUTS_PATCH
#include "cyclelayouts.c"
-#endif // CYCLELAYOUTS_PATCH
+#endif
#if PERTAG_PATCH
#include "pertag.c"
@@ -38,6 +44,28 @@
#include "togglefullscreen.c"
#endif
+#if VANITYGAPS_PATCH
+#include "vanitygaps.c"
+#endif
+
#if ZOOMSWAP_PATCH
#include "zoomswap.c"
#endif
+
+/* Layouts */
+
+#if BSTACK_LAYOUT
+#include "bstack.c"
+#endif
+
+#if BSTACKHORIZ_LAYOUT
+#include "bstackhoriz.c"
+#endif
+
+#if MONOCLE_LAYOUT
+#include "monocle.c"
+#endif
+
+#if TILE_LAYOUT
+#include "tile.c"
+#endif \ No newline at end of file
diff --git a/patch/include.h b/patch/include.h
index e324b55..bd68e54 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -1,3 +1,5 @@
+/* Patches */
+
#if ALPHA_PATCH
#include "alpha.h"
#endif
@@ -10,6 +12,10 @@
#include "autostart.h"
#endif
+#if CFACTS_PATCH
+#include "cfacts.h"
+#endif
+
#if CYCLELAYOUTS_PATCH
#include "cyclelayouts.h"
#endif
@@ -34,6 +40,28 @@
#include "togglefullscreen.h"
#endif
+#if VANITYGAPS_PATCH
+#include "vanitygaps.h"
+#endif
+
#if ZOOMSWAP_PATCH
#include "zoomswap.h"
+#endif
+
+/* Layouts */
+
+#if BSTACK_LAYOUT
+#include "bstack.h"
+#endif
+
+#if BSTACKHORIZ_LAYOUT
+#include "bstackhoriz.h"
+#endif
+
+#if MONOCLE_LAYOUT
+#include "monocle.h"
+#endif
+
+#if TILE_LAYOUT
+#include "tile.h"
#endif \ No newline at end of file
diff --git a/patch/monocle.c b/patch/monocle.c
new file mode 100644
index 0000000..5d7a270
--- /dev/null
+++ b/patch/monocle.c
@@ -0,0 +1,14 @@
+void
+monocle(Monitor *m)
+{
+ unsigned int n = 0;
+ Client *c;
+
+ for (c = m->clients; c; c = c->next)
+ if (ISVISIBLE(c))
+ n++;
+ if (n > 0) /* override layout symbol */
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
+ for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+} \ No newline at end of file
diff --git a/patch/monocle.h b/patch/monocle.h
new file mode 100644
index 0000000..d3df960
--- /dev/null
+++ b/patch/monocle.h
@@ -0,0 +1 @@
+static void monocle(Monitor *m); \ No newline at end of file
diff --git a/patch/tile.c b/patch/tile.c
new file mode 100644
index 0000000..866a684
--- /dev/null
+++ b/patch/tile.c
@@ -0,0 +1,140 @@
+#if VANITYGAPS_PATCH && CFACTS_PATCH
+static void
+tile(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ float mfacts, sfacts;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n, &mfacts, &sfacts);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1);
+ sw = mw = m->ww - 2*ov;
+
+ if (m->nmaster && n > m->nmaster) {
+ sw = (mw - iv) * (1 - m->mfact);
+ mw = (mw - iv) * m->mfact;
+ sx = mx + mw + iv;
+ sh = m->wh - 2*oh - ih * (n - m->nmaster - 1);
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw - (2*c->bw), mh * (c->cfact / mfacts) - (2*c->bw), 0);
+ my += HEIGHT(c) + ih;
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh * (c->cfact / sfacts) - (2*c->bw), 0);
+ sy += HEIGHT(c) + ih;
+ }
+}
+#elif VANITYGAPS_PATCH
+static void
+tile(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx + ov;
+ sy = my = m->wy + oh;
+ sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1);
+ sw = mw = m->ww - 2*ov;
+
+ if (m->nmaster && n > m->nmaster) {
+ sw = (mw - iv) * (1 - m->mfact);
+ mw = (mw - iv) * m->mfact;
+ sx = mx + mw + iv;
+ sh = m->wh - 2*oh - ih * (n - m->nmaster - 1);
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw - (2*c->bw), mh / MIN(n, m->nmaster) - (2*c->bw), 0);
+ my += HEIGHT(c) + ih;
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh / (n - MIN(n, m->nmaster)) - (2*c->bw), 0);
+ sy += HEIGHT(c) + ih;
+ }
+}
+#elif CFACTS_PATCH
+static void
+tile(Monitor *m)
+{
+ unsigned int i, n;
+ int mx = 0, my = 0, mh = 0, mw = 0;
+ int sx = 0, sy = 0, sh = 0, sw = 0;
+ float mfacts = 1, sfacts = 1;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
+ if (n < m->nmaster)
+ mfacts += c->cfact;
+ else
+ sfacts += c->cfact;
+ }
+
+ if (n == 0)
+ return;
+
+ sx = mx = m->wx;
+ sy = my = m->wy;
+ sh = mh = m->wh;
+ sw = mw = m->ww;
+
+ if (m->nmaster && n > m->nmaster) {
+ sw = mw * (1 - m->mfact);
+ mw = mw * m->mfact;
+ sx = mx + mw;
+ }
+
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ resize(c, mx, my, mw - (2*c->bw), mh * (c->cfact / mfacts) - (2*c->bw), 0);
+ my += HEIGHT(c);
+ } else {
+ resize(c, sx, sy, sw - (2*c->bw), sh * (c->cfact / sfacts) - (2*c->bw), 0);
+ sy += HEIGHT(c);
+ }
+}
+#else
+void
+tile(Monitor *m)
+{
+ unsigned int i, n, h, mw, my, ty;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+
+ if (n > m->nmaster)
+ mw = m->nmaster ? m->ww * m->mfact : 0;
+ else
+ mw = m->ww;
+ for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
+ my += HEIGHT(c);
+ } else {
+ h = (m->wh - ty) / (n - i);
+ resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
+ ty += HEIGHT(c);
+ }
+}
+#endif \ No newline at end of file
diff --git a/patch/tile.h b/patch/tile.h
new file mode 100644
index 0000000..8730e13
--- /dev/null
+++ b/patch/tile.h
@@ -0,0 +1 @@
+static void tile(Monitor *); \ No newline at end of file
diff --git a/patch/vanitygaps.c b/patch/vanitygaps.c
new file mode 100644
index 0000000..b8c1557
--- /dev/null
+++ b/patch/vanitygaps.c
@@ -0,0 +1,143 @@
+/* Settings */
+static int enablegaps = 1;
+
+static void
+setgaps(int oh, int ov, int ih, int iv)
+{
+ if (oh < 0) oh = 0;
+ if (ov < 0) ov = 0;
+ if (ih < 0) ih = 0;
+ if (iv < 0) iv = 0;
+
+ selmon->gappoh = oh;
+ selmon->gappov = ov;
+ selmon->gappih = ih;
+ selmon->gappiv = iv;
+ arrange(selmon);
+}
+
+static void
+togglegaps(const Arg *arg)
+{
+ enablegaps = !enablegaps;
+ arrange(NULL);
+}
+
+static void
+defaultgaps(const Arg *arg)
+{
+ setgaps(gappoh, gappov, gappih, gappiv);
+}
+
+static void
+incrgaps(const Arg *arg)
+{
+ setgaps(
+ selmon->gappoh + arg->i,
+ selmon->gappov + arg->i,
+ selmon->gappih + arg->i,
+ selmon->gappiv + arg->i
+ );
+}
+
+static void
+incrigaps(const Arg *arg)
+{
+ setgaps(
+ selmon->gappoh,
+ selmon->gappov,
+ selmon->gappih + arg->i,
+ selmon->gappiv + arg->i
+ );
+}
+
+static void
+incrogaps(const Arg *arg)
+{
+ setgaps(
+ selmon->gappoh + arg->i,
+ selmon->gappov + arg->i,
+ selmon->gappih,
+ selmon->gappiv
+ );
+}
+
+static void
+incrohgaps(const Arg *arg)
+{
+ setgaps(
+ selmon->gappoh + arg->i,
+ selmon->gappov,
+ selmon->gappih,
+ selmon->gappiv
+ );
+}
+
+static void
+incrovgaps(const Arg *arg)
+{
+ setgaps(
+ selmon->gappoh,
+ selmon->gappov + arg->i,
+ selmon->gappih,
+ selmon->gappiv
+ );
+}
+
+static void
+incrihgaps(const Arg *arg)
+{
+ setgaps(
+ selmon->gappoh,
+ selmon->gappov,
+ selmon->gappih + arg->i,
+ selmon->gappiv
+ );
+}
+
+static void
+incrivgaps(const Arg *arg)
+{
+ setgaps(
+ selmon->gappoh,
+ selmon->gappov,
+ selmon->gappih,
+ selmon->gappiv + arg->i
+ );
+}
+
+static void
+#if CFACTS_PATCH
+getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc, float *mf, float *sf)
+#else
+getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc )
+#endif // CFACTS_PATCH
+{
+ unsigned int n, oe = enablegaps, ie = enablegaps;
+ #if CFACTS_PATCH
+ float mfacts = 0, sfacts = 0;
+ #endif // CFACTS_PATCH
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
+ #if CFACTS_PATCH
+ if (!m->nmaster || n < m->nmaster)
+ mfacts += c->cfact;
+ else
+ sfacts += c->cfact;
+ #endif // CFACTS_PATCH
+ }
+ if (smartgaps && n == 1) {
+ oe = 0; // outer gaps disabled when only one client
+ }
+
+ *oh = m->gappoh*oe; // outer horizontal gap
+ *ov = m->gappov*oe; // outer vertical gap
+ *ih = m->gappih*ie; // inner horizontal gap
+ *iv = m->gappiv*ie; // inner vertical gap
+ *nc = n; // number of clients
+ #if CFACTS_PATCH
+ *mf = mfacts; // total factor of master area
+ *sf = sfacts; // total factor of slave area
+ #endif // CFACTS_PATCH
+} \ No newline at end of file
diff --git a/patch/vanitygaps.h b/patch/vanitygaps.h
new file mode 100644
index 0000000..bb1df18
--- /dev/null
+++ b/patch/vanitygaps.h
@@ -0,0 +1,18 @@
+/* Key binding functions */
+static void defaultgaps(const Arg *arg);
+static void incrgaps(const Arg *arg);
+static void incrigaps(const Arg *arg);
+static void incrogaps(const Arg *arg);
+static void incrohgaps(const Arg *arg);
+static void incrovgaps(const Arg *arg);
+static void incrihgaps(const Arg *arg);
+static void incrivgaps(const Arg *arg);
+static void togglegaps(const Arg *arg);
+
+/* Internals */
+#if CFACTS_PATCH
+static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc, float *mf, float *sf);
+#else
+static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
+#endif // CFACTS_PATCH
+static void setgaps(int oh, int ov, int ih, int iv); \ No newline at end of file