summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--patch/bstack.c15
-rw-r--r--patch/bstackhoriz.c15
-rw-r--r--patch/cfacts.c16
-rw-r--r--patch/cfacts.h1
-rw-r--r--patch/deck.c16
-rw-r--r--patch/gapplessgrid.c76
-rw-r--r--patch/gapplessgrid.h1
-rw-r--r--patch/include.c4
-rw-r--r--patch/include.h4
-rw-r--r--patch/tile.c15
-rw-r--r--patch/vanitygaps.c22
-rw-r--r--patch/vanitygaps.h4
-rw-r--r--patches.h15
14 files changed, 143 insertions, 68 deletions
diff --git a/README.md b/README.md
index da4793b..ac72672 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
-2019-09-09 - Added deck, fibonacci (dwindle and spiral) layouts
+2019-09-09 - Added deck, fibonacci (dwindle and spiral) and gapplessgrid layouts
2019-09-08 - Added cfacts and vanitygaps patches, added bstack and bstackhoriz layouts
@@ -119,4 +119,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- deck layout
- [fibonacci](https://dwm.suckless.org/patches/fibonacci/)
- - fibonacci (dwindle and spiral) layouts \ No newline at end of file
+ - fibonacci (dwindle and spiral) layouts
+
+ - [gapplessgrid](https://dwm.suckless.org/patches/gaplessgrid/)
+ - gappless grid layout \ No newline at end of file
diff --git a/patch/bstack.c b/patch/bstack.c
index d202e06..c171e2d 100644
--- a/patch/bstack.c
+++ b/patch/bstack.c
@@ -9,7 +9,8 @@ bstack(Monitor *m)
float mfacts, sfacts;
Client *c;
- getgaps(m, &oh, &ov, &ih, &iv, &n, &mfacts, &sfacts);
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+ getfacts(m, &mfacts, &sfacts);
if (n == 0)
return;
@@ -81,19 +82,15 @@ 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;
+ float mfacts, sfacts;
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;
- }
-
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
+ getfacts(m, &mfacts, &sfacts);
+
sx = mx = m->wx;
sy = my = m->wy;
sh = mh = m->wh;
diff --git a/patch/bstackhoriz.c b/patch/bstackhoriz.c
index 3a4d11a..b4010fa 100644
--- a/patch/bstackhoriz.c
+++ b/patch/bstackhoriz.c
@@ -9,7 +9,8 @@ bstackhoriz(Monitor *m)
float mfacts, sfacts;
Client *c;
- getgaps(m, &oh, &ov, &ih, &iv, &n, &mfacts, &sfacts);
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+ getfacts(m, &mfacts, &sfacts);
if (n == 0)
return;
@@ -82,19 +83,15 @@ 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;
+ float mfacts, sfacts;
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;
- }
-
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
+ getfacts(m, &mfacts, &sfacts);
+
sx = mx = m->wx;
sy = my = m->wy;
sh = mh = m->wh;
diff --git a/patch/cfacts.c b/patch/cfacts.c
index 085071f..b193c92 100644
--- a/patch/cfacts.c
+++ b/patch/cfacts.c
@@ -14,4 +14,20 @@ setcfact(const Arg *arg) {
return;
c->cfact = f;
arrange(selmon);
+}
+
+void
+getfacts(Monitor *m, float *mf, float *sf)
+{
+ float mfacts = 0, sfacts = 0;
+ Client *c;
+
+ for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
+ if (!m->nmaster || n < m->nmaster)
+ mfacts += c->cfact;
+ else
+ sfacts += c->cfact;
+ }
+ *mf = mfacts; // total factor of master area
+ *sf = sfacts; // total factor of slave area
} \ No newline at end of file
diff --git a/patch/cfacts.h b/patch/cfacts.h
index b8d8b04..86d6ef8 100644
--- a/patch/cfacts.h
+++ b/patch/cfacts.h
@@ -1 +1,2 @@
+static void getfacts(Monitor *m, float *mf, float *sf)
static void setcfact(const Arg *arg); \ No newline at end of file
diff --git a/patch/deck.c b/patch/deck.c
index 5da36a8..98d0794 100644
--- a/patch/deck.c
+++ b/patch/deck.c
@@ -9,7 +9,8 @@ deck(Monitor *m)
float mfacts, sfacts;
Client *c;
- getgaps(m, &oh, &ov, &ih, &iv, &n, &mfacts, &sfacts);
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+ getfacts(m, &mfacts, &sfacts);
if (n == 0)
return;
@@ -82,19 +83,15 @@ deck(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;
+ float mfacts, sfacts;
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;
- }
-
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
+ getfacts(m, &mfacts, &sfacts);
+
sx = mx = m->wx;
sy = my = m->wy;
sh = mh = m->wh;
@@ -127,7 +124,6 @@ deck(Monitor *m)
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
-
if (n == 0)
return;
diff --git a/patch/gapplessgrid.c b/patch/gapplessgrid.c
new file mode 100644
index 0000000..52cb627
--- /dev/null
+++ b/patch/gapplessgrid.c
@@ -0,0 +1,76 @@
+#if VANITYGAPS_PATCH
+void
+gaplessgrid(Monitor *m)
+{
+ unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
+ int oh, ov, ih, iv;
+ Client *c;
+
+ getgaps(m, &oh, &ov, &ih, &iv, &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->ww - 2*ov - iv*(cols - 1)) / cols : m->ww - 2*ov;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
+ if (i/rows + 1 > cols - n%cols)
+ rows = n/cols + 1;
+ ch = rows ? (m->wh - 2*oh - ih*(rows - 1)) / rows : m->wh - 2*oh;
+ cx = m->wx + ov + cn*(cw + iv);
+ cy = m->wy + oh + rn*(ch + ih);
+ resize(c, cx, cy, cw - 2*c->bw, ch - 2*c->bw, False);
+ rn++;
+ if (rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ }
+}
+#else
+void
+gaplessgrid(Monitor *m) {
+ unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
+ Client *c;
+
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), 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->ww / cols : m->ww;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
+ if(i/rows + 1 > cols - n%cols)
+ rows = n/cols + 1;
+ ch = rows ? m->wh / rows : m->wh;
+ cx = m->wx + cn*cw;
+ cy = m->wy + rn*ch;
+ resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
+ rn++;
+ if(rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ }
+}
+#endif \ No newline at end of file
diff --git a/patch/gapplessgrid.h b/patch/gapplessgrid.h
new file mode 100644
index 0000000..28a7b5d
--- /dev/null
+++ b/patch/gapplessgrid.h
@@ -0,0 +1 @@
+static void gaplessgrid(Monitor *m); \ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index 7dc0aac..79b9eb6 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -70,6 +70,10 @@
#include "fibonacci.c"
#endif
+#if GAPPLESSGRID_LAYOUT
+#include "gapplessgrid.c"
+#endif
+
#if MONOCLE_LAYOUT
#include "monocle.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index af229ea..caa6190 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -66,6 +66,10 @@
#include "fibonacci.h"
#endif
+#if GAPPLESSGRID_LAYOUT
+#include "gapplessgrid.h"
+#endif
+
#if MONOCLE_LAYOUT
#include "monocle.h"
#endif
diff --git a/patch/tile.c b/patch/tile.c
index 866a684..c8f74c9 100644
--- a/patch/tile.c
+++ b/patch/tile.c
@@ -9,7 +9,8 @@ tile(Monitor *m)
float mfacts, sfacts;
Client *c;
- getgaps(m, &oh, &ov, &ih, &iv, &n, &mfacts, &sfacts);
+ getgaps(m, &oh, &ov, &ih, &iv, &n);
+ getfacts(m, &mfacts, &sfacts);
if (n == 0)
return;
@@ -78,19 +79,15 @@ 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;
+ float mfacts, sfacts;
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;
- }
-
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
+ getfacts(m, &mfacts, &sfacts);
+
sx = mx = m->wx;
sy = my = m->wy;
sh = mh = m->wh;
diff --git a/patch/vanitygaps.c b/patch/vanitygaps.c
index b8c1557..b46944d 100644
--- a/patch/vanitygaps.c
+++ b/patch/vanitygaps.c
@@ -107,26 +107,12 @@ incrivgaps(const Arg *arg)
}
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
+getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
{
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
- }
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (smartgaps && n == 1) {
oe = 0; // outer gaps disabled when only one client
}
@@ -136,8 +122,4 @@ getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc )
*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
index bb1df18..74486d1 100644
--- a/patch/vanitygaps.h
+++ b/patch/vanitygaps.h
@@ -10,9 +10,5 @@ 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
diff --git a/patches.h b/patches.h
index 1c5df12..54234ab 100644
--- a/patches.h
+++ b/patches.h
@@ -190,27 +190,32 @@
/* Bottomstack layout.
* https://dwm.suckless.org/patches/bottomstack/
*/
-#define BSTACK_LAYOUT 0
+#define BSTACK_LAYOUT 1
/* Bottomstack horizontal layout.
* https://dwm.suckless.org/patches/bottomstack/
*/
-#define BSTACKHORIZ_LAYOUT 0
+#define BSTACKHORIZ_LAYOUT 1
/* Deck layout.
* https://dwm.suckless.org/patches/deck/
*/
-#define DECK_LAYOUT 0
+#define DECK_LAYOUT 1
/* Fibonacci dwindle layout.
* https://dwm.suckless.org/patches/fibonacci/
*/
-#define FIBONACCI_DWINDLE_LAYOUT 0
+#define FIBONACCI_DWINDLE_LAYOUT 1
/* Fibonacci spiral layout.
* https://dwm.suckless.org/patches/fibonacci/
*/
-#define FIBONACCI_SPIRAL_LAYOUT 0
+#define FIBONACCI_SPIRAL_LAYOUT 1
+
+/* Gappless grid layout.
+ * https://dwm.suckless.org/patches/gaplessgrid/
+ */
+#define GAPPLESSGRID_LAYOUT 1
/* The default tile layout.
* This can be optionally disabled in favour of other layouts.