mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding tatami layout option for flextile
This commit is contained in:
parent
15895c42b9
commit
0f14ffade1
@ -540,6 +540,7 @@ static const Layout layouts[] = {
|
|||||||
{ ":::", flextile, { -1, -1, NO_SPLIT, GAPPLESSGRID, GAPPLESSGRID, 0, NULL } }, // gappless grid
|
{ ":::", flextile, { -1, -1, NO_SPLIT, GAPPLESSGRID, GAPPLESSGRID, 0, NULL } }, // gappless grid
|
||||||
{ "[\\]", flextile, { -1, -1, NO_SPLIT, DWINDLE, DWINDLE, 0, NULL } }, // fibonacci dwindle
|
{ "[\\]", flextile, { -1, -1, NO_SPLIT, DWINDLE, DWINDLE, 0, NULL } }, // fibonacci dwindle
|
||||||
{ "(@)", flextile, { -1, -1, NO_SPLIT, SPIRAL, SPIRAL, 0, NULL } }, // fibonacci spiral
|
{ "(@)", flextile, { -1, -1, NO_SPLIT, SPIRAL, SPIRAL, 0, NULL } }, // fibonacci spiral
|
||||||
|
{ "[T]", flextile, { -1, -1, SPLIT_VERTICAL, LEFT_TO_RIGHT, TATAMI, 0, NULL } }, // tatami mats
|
||||||
#if TILE_LAYOUT
|
#if TILE_LAYOUT
|
||||||
{ "[]=", tile, {0} },
|
{ "[]=", tile, {0} },
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,6 +35,7 @@ static const TileArranger flextiles[] = {
|
|||||||
{ arrange_horizgrid },
|
{ arrange_horizgrid },
|
||||||
{ arrange_dwindle },
|
{ arrange_dwindle },
|
||||||
{ arrange_spiral },
|
{ arrange_spiral },
|
||||||
|
{ arrange_tatami },
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
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) {
|
if (s) {
|
||||||
ny += nh + ih;
|
ny += nh + ih;
|
||||||
nh += hrest;
|
nh += hrest;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
nh -= hrest;
|
nh -= hrest;
|
||||||
ny -= nh + ih;
|
ny -= nh + ih;
|
||||||
}
|
}
|
||||||
}
|
} else if ((i % 4) == 1) {
|
||||||
else if ((i % 4) == 1) {
|
|
||||||
nx += nw + iv;
|
nx += nw + iv;
|
||||||
nw += wrest;
|
nw += wrest;
|
||||||
}
|
} else if ((i % 4) == 2) {
|
||||||
else if ((i % 4) == 2) {
|
|
||||||
ny += nh + ih;
|
ny += nh + ih;
|
||||||
nh += hrest;
|
nh += hrest;
|
||||||
if (i < n - 1)
|
if (i < n - 1)
|
||||||
nw += wrest;
|
nw += wrest;
|
||||||
}
|
} else if ((i % 4) == 3) {
|
||||||
else if ((i % 4) == 3) {
|
|
||||||
if (s) {
|
if (s) {
|
||||||
nx += nw + iv;
|
nx += nw + iv;
|
||||||
nw -= wrest;
|
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;
|
wrest = 0;
|
||||||
}
|
}
|
||||||
ny = y;
|
ny = y;
|
||||||
}
|
} else if (i == 1)
|
||||||
else if (i == 1)
|
|
||||||
nw = w - nw - iv;
|
nw = w - nw - iv;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -616,6 +612,130 @@ arrange_spiral(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, in
|
|||||||
arrange_fibonacci(m, x, y, h, w, ih, iv, n, an, ai, 0);
|
arrange_fibonacci(m, x, y, h, w, ih, iv, n, an, ai, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
flextile(Monitor *m)
|
flextile(Monitor *m)
|
||||||
{
|
{
|
||||||
|
@ -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_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_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_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 */
|
/* Named flextile constants */
|
||||||
enum {
|
enum {
|
||||||
@ -100,6 +101,7 @@ enum {
|
|||||||
HORIZGRID, // clients are arranged in a horizontal grid
|
HORIZGRID, // clients are arranged in a horizontal grid
|
||||||
DWINDLE, // clients are arranged in fibonacci dwindle mode
|
DWINDLE, // clients are arranged in fibonacci dwindle mode
|
||||||
SPIRAL, // clients are arranged in fibonacci spiral mode
|
SPIRAL, // clients are arranged in fibonacci spiral mode
|
||||||
|
TATAMI, // clients are arranged as tatami mats
|
||||||
AXIS_LAST,
|
AXIS_LAST,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,4 +116,5 @@ static char tilesymb[] = {
|
|||||||
126, // "~",
|
126, // "~",
|
||||||
92, // "\\",
|
92, // "\\",
|
||||||
64, // "@",
|
64, // "@",
|
||||||
|
84, // "T",
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user