mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 12:05:45 +00:00
Adding two new variants of gappless grid to flextile as well as making horizgrid pixel perfect
This commit is contained in:
parent
e9e32d28c7
commit
1bd0871daf
@ -29,6 +29,8 @@ static const TileArranger flextiles[] = {
|
|||||||
{ arrange_left_to_right },
|
{ arrange_left_to_right },
|
||||||
{ arrange_monocle },
|
{ arrange_monocle },
|
||||||
{ arrange_gapplessgrid },
|
{ arrange_gapplessgrid },
|
||||||
|
{ arrange_gapplessgrid_alt1 },
|
||||||
|
{ arrange_gapplessgrid_alt2 },
|
||||||
{ arrange_gridmode },
|
{ arrange_gridmode },
|
||||||
{ arrange_horizgrid },
|
{ arrange_horizgrid },
|
||||||
{ arrange_dwindle },
|
{ arrange_dwindle },
|
||||||
@ -325,6 +327,9 @@ arrange_left_to_right(Monitor *m, int x, int y, int h, int w, int ih, int iv, in
|
|||||||
float facts, fact = 1;
|
float facts, fact = 1;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
|
if (ai + an > n)
|
||||||
|
an = n - ai;
|
||||||
|
|
||||||
w -= iv * (an - 1);
|
w -= iv * (an - 1);
|
||||||
getfactsforrange(m, an, ai, w, &rest, &facts);
|
getfactsforrange(m, an, ai, w, &rest, &facts);
|
||||||
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
@ -345,6 +350,9 @@ arrange_top_to_bottom(Monitor *m, int x, int y, int h, int w, int ih, int iv, in
|
|||||||
float facts, fact = 1;
|
float facts, fact = 1;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
|
if (ai + an > n)
|
||||||
|
an = n - ai;
|
||||||
|
|
||||||
h -= ih * (an - 1);
|
h -= ih * (an - 1);
|
||||||
getfactsforrange(m, an, ai, h, &rest, &facts);
|
getfactsforrange(m, an, ai, h, &rest, &facts);
|
||||||
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
@ -396,8 +404,7 @@ arrange_gridmode(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n,
|
|||||||
static void
|
static void
|
||||||
arrange_horizgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai)
|
arrange_horizgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai)
|
||||||
{
|
{
|
||||||
int ntop, nbottom, i;
|
int ntop, nbottom, rh, rest;
|
||||||
Client *c;
|
|
||||||
|
|
||||||
/* Exception when there is only one client; don't split into two rows */
|
/* Exception when there is only one client; don't split into two rows */
|
||||||
if (an == 1) {
|
if (an == 1) {
|
||||||
@ -407,28 +414,10 @@ arrange_horizgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n,
|
|||||||
|
|
||||||
ntop = an / 2;
|
ntop = an / 2;
|
||||||
nbottom = an - ntop;
|
nbottom = an - ntop;
|
||||||
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
rh = (h - ih) / 2;
|
||||||
if (i >= ai && i < (ai + an)) {
|
rest = h - ih - rh * 2;
|
||||||
if ((i - ai) < ntop)
|
arrange_left_to_right(m, x, y, rh + rest, w, ih, iv, n, ntop, ai);
|
||||||
resize(
|
arrange_left_to_right(m, x, y + rh + ih + rest, rh, w, ih, iv, n, nbottom, ai + ntop);
|
||||||
c,
|
|
||||||
x + (i - ai) * ((w - iv*(ntop - 1)) / ntop + iv),
|
|
||||||
y,
|
|
||||||
(w - iv*(ntop - 1)) / ntop - (2*c->bw),
|
|
||||||
(h - ih) / 2 - (2*c->bw),
|
|
||||||
False
|
|
||||||
);
|
|
||||||
else
|
|
||||||
resize(
|
|
||||||
c,
|
|
||||||
x + (i - ai - ntop) * ((w - iv*(nbottom - 1)) / nbottom + iv),
|
|
||||||
y + ih + (h - ih) / 2,
|
|
||||||
(w - iv*(nbottom - 1)) / nbottom - (2*c->bw),
|
|
||||||
(h - ih) / 2 - (2*c->bw),
|
|
||||||
False
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -466,6 +455,46 @@ arrange_gapplessgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This version of gappless grid fills rows first */
|
||||||
|
static void
|
||||||
|
arrange_gapplessgrid_alt1(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai)
|
||||||
|
{
|
||||||
|
int i, cols, rows, rest, ch;
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for (cols = 1; cols <= an/2; cols++)
|
||||||
|
if (cols*cols >= an)
|
||||||
|
break;
|
||||||
|
rows = (cols && (cols - 1) * cols >= an) ? cols - 1 : cols;
|
||||||
|
ch = (h - ih * (rows - 1)) / (rows ? rows : 1);
|
||||||
|
rest = (h - ih * (rows - 1)) - ch * rows;
|
||||||
|
|
||||||
|
for (i = 0; i < rows; i++) {
|
||||||
|
arrange_left_to_right(m, x, y, ch + (i < rest ? 1 : 0), w, ih, iv, n, cols, ai + i*cols);
|
||||||
|
y += ch + (i < rest ? 1 : 0) + ih;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This version of gappless grid fills columns first */
|
||||||
|
static void
|
||||||
|
arrange_gapplessgrid_alt2(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai)
|
||||||
|
{
|
||||||
|
int i, cols, rows, rest, cw;
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for (rows = 0; rows <= an/2; rows++)
|
||||||
|
if (rows*rows >= an)
|
||||||
|
break;
|
||||||
|
cols = (rows && (rows - 1) * rows >= an) ? rows - 1 : rows;
|
||||||
|
cw = (w - iv * (cols - 1)) / (cols ? cols : 1);
|
||||||
|
rest = (w - iv * (cols - 1)) - cw * cols;
|
||||||
|
|
||||||
|
for (i = 0; i < cols; i++) {
|
||||||
|
arrange_top_to_bottom(m, x, y, h, cw + (i < rest ? 1 : 0), ih, iv, n, rows, ai + i*rows);
|
||||||
|
x += cw + (i < rest ? 1 : 0) + iv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
arrange_fibonacci(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai, int s)
|
arrange_fibonacci(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai, int s)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,8 @@ static void arrange_left_to_right(Monitor *m, int ax, int ay, int ah, int aw, in
|
|||||||
static void arrange_top_to_bottom(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
static void arrange_top_to_bottom(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
||||||
static void arrange_monocle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
static void arrange_monocle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
||||||
static void arrange_gapplessgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
static void arrange_gapplessgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
||||||
|
static void arrange_gapplessgrid_alt1(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
||||||
|
static void arrange_gapplessgrid_alt2(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
||||||
static void arrange_gridmode(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
|
static void arrange_gridmode(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_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);
|
||||||
@ -84,14 +86,16 @@ static char layoutsymb[] = {
|
|||||||
|
|
||||||
/* Tile arrangements */
|
/* Tile arrangements */
|
||||||
enum {
|
enum {
|
||||||
TOP_TO_BOTTOM, // clients are stacked vertically
|
TOP_TO_BOTTOM, // clients are arranged vertically
|
||||||
LEFT_TO_RIGHT, // clients are stacked horizontally
|
LEFT_TO_RIGHT, // clients are arranged horizontally
|
||||||
MONOCLE, // clients are stacked in deck / monocle mode
|
MONOCLE, // clients are arranged in deck / monocle mode
|
||||||
GAPPLESSGRID, // clients are stacked in a gappless grid
|
GAPPLESSGRID, // clients are arranged in a gappless grid (original formula)
|
||||||
GRIDMODE, // clients are stacked in a grid
|
GAPPLESSGRID_ALT1, // clients are arranged in a gappless grid (alt. 1, fills rows first)
|
||||||
HORIZGRID, // clients are stacked in a grid
|
GAPPLESSGRID_ALT2, // clients are arranged in a gappless grid (alt. 2, fills columns first)
|
||||||
DWINDLE, // clients are stacked in fibonacci dwindle mode
|
GRIDMODE, // clients are arranged in a grid
|
||||||
SPIRAL, // clients are stacked in fibonacci spiral mode
|
HORIZGRID, // clients are arranged in a horizontal grid
|
||||||
|
DWINDLE, // clients are arranged in fibonacci dwindle mode
|
||||||
|
SPIRAL, // clients are arranged in fibonacci spiral mode
|
||||||
AXIS_LAST,
|
AXIS_LAST,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -99,9 +103,11 @@ static char tilesymb[] = {
|
|||||||
61, // "=",
|
61, // "=",
|
||||||
124, // "|",
|
124, // "|",
|
||||||
68, // "D",
|
68, // "D",
|
||||||
|
71, // "G",
|
||||||
|
49, // "1",
|
||||||
|
50, // "2"
|
||||||
35, // "#",
|
35, // "#",
|
||||||
35, // "#",
|
126, // "~",
|
||||||
35, // "#",
|
|
||||||
92, // "\\",
|
92, // "\\",
|
||||||
64, // "@",
|
64, // "@",
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user