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_monocle },
|
||||
{ arrange_gapplessgrid },
|
||||
{ arrange_gapplessgrid_alt1 },
|
||||
{ arrange_gapplessgrid_alt2 },
|
||||
{ arrange_gridmode },
|
||||
{ arrange_horizgrid },
|
||||
{ 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;
|
||||
Client *c;
|
||||
|
||||
if (ai + an > n)
|
||||
an = n - ai;
|
||||
|
||||
w -= iv * (an - 1);
|
||||
getfactsforrange(m, an, ai, w, &rest, &facts);
|
||||
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;
|
||||
Client *c;
|
||||
|
||||
if (ai + an > n)
|
||||
an = n - ai;
|
||||
|
||||
h -= ih * (an - 1);
|
||||
getfactsforrange(m, an, ai, h, &rest, &facts);
|
||||
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
|
||||
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;
|
||||
Client *c;
|
||||
int ntop, nbottom, rh, rest;
|
||||
|
||||
/* Exception when there is only one client; don't split into two rows */
|
||||
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;
|
||||
nbottom = an - ntop;
|
||||
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||
if (i >= ai && i < (ai + an)) {
|
||||
if ((i - ai) < ntop)
|
||||
resize(
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
rh = (h - ih) / 2;
|
||||
rest = h - ih - rh * 2;
|
||||
arrange_left_to_right(m, x, y, rh + rest, w, ih, iv, n, ntop, ai);
|
||||
arrange_left_to_right(m, x, y + rh + ih + rest, rh, w, ih, iv, n, nbottom, ai + ntop);
|
||||
}
|
||||
|
||||
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
|
||||
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_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_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_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);
|
||||
@ -84,14 +86,16 @@ static char layoutsymb[] = {
|
||||
|
||||
/* Tile arrangements */
|
||||
enum {
|
||||
TOP_TO_BOTTOM, // clients are stacked vertically
|
||||
LEFT_TO_RIGHT, // clients are stacked horizontally
|
||||
MONOCLE, // clients are stacked in deck / monocle mode
|
||||
GAPPLESSGRID, // clients are stacked in a gappless grid
|
||||
GRIDMODE, // clients are stacked in a grid
|
||||
HORIZGRID, // clients are stacked in a grid
|
||||
DWINDLE, // clients are stacked in fibonacci dwindle mode
|
||||
SPIRAL, // clients are stacked in fibonacci spiral mode
|
||||
TOP_TO_BOTTOM, // clients are arranged vertically
|
||||
LEFT_TO_RIGHT, // clients are arranged horizontally
|
||||
MONOCLE, // clients are arranged in deck / monocle mode
|
||||
GAPPLESSGRID, // clients are arranged in a gappless grid (original formula)
|
||||
GAPPLESSGRID_ALT1, // clients are arranged in a gappless grid (alt. 1, fills rows first)
|
||||
GAPPLESSGRID_ALT2, // clients are arranged in a gappless grid (alt. 2, fills columns first)
|
||||
GRIDMODE, // clients are arranged in a grid
|
||||
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,
|
||||
};
|
||||
|
||||
@ -99,9 +103,11 @@ static char tilesymb[] = {
|
||||
61, // "=",
|
||||
124, // "|",
|
||||
68, // "D",
|
||||
71, // "G",
|
||||
49, // "1",
|
||||
50, // "2"
|
||||
35, // "#",
|
||||
35, // "#",
|
||||
35, // "#",
|
||||
126, // "~",
|
||||
92, // "\\",
|
||||
64, // "@",
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user