summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2021-02-18 14:30:20 +0100
committerbakkeby <[email protected]>2021-02-18 14:30:20 +0100
commit0f14ffade168db0f86c511fbbd0fb1561f48c363 (patch)
tree4f27e16555a31927b1ba56833bc4592d37bd101e /patch
parent15895c42b9baab8ba91b8e0a9c9b61180b1cb48c (diff)
downloaddwm-flexipatch-0f14ffade168db0f86c511fbbd0fb1561f48c363.tar.gz
dwm-flexipatch-0f14ffade168db0f86c511fbbd0fb1561f48c363.zip
Adding tatami layout option for flextile
Diffstat (limited to 'patch')
-rw-r--r--patch/layout_flextile-deluxe.c140
-rw-r--r--patch/layout_flextile-deluxe.h3
2 files changed, 133 insertions, 10 deletions
diff --git a/patch/layout_flextile-deluxe.c b/patch/layout_flextile-deluxe.c
index 96bc04b..3f5cc27 100644
--- a/patch/layout_flextile-deluxe.c
+++ b/patch/layout_flextile-deluxe.c
@@ -35,6 +35,7 @@ static const TileArranger flextiles[] = {
{ arrange_horizgrid },
{ arrange_dwindle },
{ arrange_spiral },
+ { arrange_tatami },
};
static void
@@ -561,23 +562,19 @@ arrange_fibonacci(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n,
if (s) {
ny += nh + ih;
nh += hrest;
- }
- else {
+ } else {
nh -= hrest;
ny -= nh + ih;
}
- }
- else if ((i % 4) == 1) {
+ } else if ((i % 4) == 1) {
nx += nw + iv;
nw += wrest;
- }
- else if ((i % 4) == 2) {
+ } else if ((i % 4) == 2) {
ny += nh + ih;
nh += hrest;
if (i < n - 1)
nw += wrest;
- }
- else if ((i % 4) == 3) {
+ } else if ((i % 4) == 3) {
if (s) {
nx += nw + iv;
nw -= wrest;
@@ -593,8 +590,7 @@ arrange_fibonacci(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n,
wrest = 0;
}
ny = y;
- }
- else if (i == 1)
+ } else if (i == 1)
nw = w - nw - iv;
i++;
}
@@ -617,6 +613,130 @@ arrange_spiral(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, in
}
static void
+arrange_tatami(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai)
+{
+ unsigned int i, j, nx, ny, nw, nh, tnx, tny, tnw, tnh, nhrest, hrest, wrest, areas, mats, cats;
+ Client *c;
+
+ nx = x;
+ ny = y;
+ nw = w;
+ nh = h;
+
+ mats = an / 5;
+ cats = an % 5;
+ hrest = 0;
+ wrest = 0;
+
+ areas = mats + (cats > 0);
+ nh = (h - ih * (areas - 1)) / areas;
+ nhrest = (h - ih * (areas - 1)) % areas;
+
+ for (i = 0, j = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), j++) {
+ if (j >= ai && j < (ai + an)) {
+
+ tnw = nw;
+ tnx = nx;
+ tnh = nh;
+ tny = ny;
+
+ if (j < ai + cats) {
+ /* Arrange cats (all excess clients that can't be tiled as mats). Cats sleep on mats. */
+
+ switch (cats) {
+ case 1: // fill
+ break;
+ case 2: // up and down
+ if ((i % 5) == 0) //up
+ tnh = (nh - ih) / 2 + (nh - ih) % 2;
+ else if ((i % 5) == 1) { //down
+ tny += (nh - ih) / 2 + (nh - ih) % 2 + ih;
+ tnh = (nh - ih) / 2;
+ }
+ break;
+ case 3: //bottom, up-left and up-right
+ if ((i % 5) == 0) { // up-left
+ tnw = (nw - iv) / 2 + (nw - iv) % 2;
+ tnh = (nh - ih) * 2 / 3 + (nh - ih) * 2 % 3;
+ } else if ((i % 5) == 1) { // up-right
+ tnx += (nw - iv) / 2 + (nw - iv) % 2 + iv;
+ tnw = (nw - iv) / 2;
+ tnh = (nh - ih) * 2 / 3 + (nh - ih) * 2 % 3;
+ } else if ((i % 5) == 2) { //bottom
+ tnh = (nh - ih) / 3;
+ tny += (nh - ih) * 2 / 3 + (nh - ih) * 2 % 3 + ih;
+ }
+ break;
+ case 4: // bottom, left, right and top
+ if ((i % 5) == 0) { //top
+ hrest = (nh - 2 * ih) % 4;
+ tnh = (nh - 2 * ih) / 4 + (hrest ? 1 : 0);
+ } else if ((i % 5) == 1) { // left
+ tnw = (nw - iv) / 2 + (nw - iv) % 2;
+ tny += (nh - 2 * ih) / 4 + (hrest ? 1 : 0) + ih;
+ tnh = (nh - 2 * ih) * 2 / 4 + (hrest > 1 ? 1 : 0);
+ } else if ((i % 5) == 2) { // right
+ tnx += (nw - iv) / 2 + (nw - iv) % 2 + iv;
+ tnw = (nw - iv) / 2;
+ tny += (nh - 2 * ih) / 4 + (hrest ? 1 : 0) + ih;
+ tnh = (nh - 2 * ih) * 2 / 4 + (hrest > 1 ? 1 : 0);
+ } else if ((i % 5) == 3) { // bottom
+ tny += (nh - 2 * ih) / 4 + (hrest ? 1 : 0) + (nh - 2 * ih) * 2 / 4 + (hrest > 1 ? 1 : 0) + 2 * ih;
+ tnh = (nh - 2 * ih) / 4 + (hrest > 2 ? 1 : 0);
+ }
+ break;
+ }
+
+ } else {
+ /* Arrange mats. One mat is a collection of five clients arranged tatami style */
+
+ if (((i - cats) % 5) == 0) {
+ if ((cats > 0) || ((i - cats) >= 5)) {
+ tny = ny = ny + nh + (nhrest > 0 ? 1 : 0) + ih;
+ --nhrest;
+ }
+ }
+
+ switch ((i - cats) % 5) {
+ case 0: // top-left-vert
+ wrest = (nw - 2 * iv) % 3;
+ hrest = (nh - 2 * ih) % 3;
+ tnw = (nw - 2 * iv) / 3 + (wrest ? 1 : 0);
+ tnh = (nh - 2 * ih) * 2 / 3 + hrest + iv;
+ break;
+ case 1: // top-right-hor
+ tnx += (nw - 2 * iv) / 3 + (wrest ? 1 : 0) + iv;
+ tnw = (nw - 2 * iv) * 2 / 3 + (wrest > 1 ? 1 : 0) + iv;
+ tnh = (nh - 2 * ih) / 3 + (hrest ? 1 : 0);
+ break;
+ case 2: // center
+ tnx += (nw - 2 * iv) / 3 + (wrest ? 1 : 0) + iv;
+ tnw = (nw - 2 * iv) / 3 + (wrest > 1 ? 1 : 0);
+ tny += (nh - 2 * ih) / 3 + (hrest ? 1 : 0) + ih;
+ tnh = (nh - 2 * ih) / 3 + (hrest > 1 ? 1 : 0);
+ break;
+ case 3: // bottom-right-vert
+ tnx += (nw - 2 * iv) * 2 / 3 + wrest + 2 * iv;
+ tnw = (nw - 2 * iv) / 3;
+ tny += (nh - 2 * ih) / 3 + (hrest ? 1 : 0) + ih;
+ tnh = (nh - 2 * ih) * 2 / 3 + hrest + iv;
+ break;
+ case 4: // (oldest) bottom-left-hor
+ tnw = (nw - 2 * iv) * 2 / 3 + wrest + iv;
+ tny += (nh - 2 * ih) * 2 / 3 + hrest + 2 * iv;
+ tnh = (nh - 2 * ih) / 3;
+ break;
+ }
+
+ }
+
+ resize(c, tnx, tny, tnw - 2 * c->bw, tnh - 2 * c->bw, False);
+ ++i;
+ }
+ }
+}
+
+static void
flextile(Monitor *m)
{
unsigned int n;
diff --git a/patch/layout_flextile-deluxe.h b/patch/layout_flextile-deluxe.h
index 253e76b..9ec7324 100644
--- a/patch/layout_flextile-deluxe.h
+++ b/patch/layout_flextile-deluxe.h
@@ -40,6 +40,7 @@ static void arrange_gridmode(Monitor *m, int ax, int ay, int ah, int aw, int ih,
static void arrange_horizgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_dwindle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_spiral(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
+static void arrange_tatami(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
/* Named flextile constants */
enum {
@@ -100,6 +101,7 @@ enum {
HORIZGRID, // clients are arranged in a horizontal grid
DWINDLE, // clients are arranged in fibonacci dwindle mode
SPIRAL, // clients are arranged in fibonacci spiral mode
+ TATAMI, // clients are arranged as tatami mats
AXIS_LAST,
};
@@ -114,4 +116,5 @@ static char tilesymb[] = {
126, // "~",
92, // "\\",
64, // "@",
+ 84, // "T",
};