Changes to make gapplessgrid layout arrangement pixel perfect

This commit is contained in:
bakkeby 2020-04-28 16:34:44 +02:00
parent f7bb7f4403
commit 8aa7a8dafb

View File

@ -427,7 +427,7 @@ arrange_horizgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n,
static void static void
arrange_gapplessgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) arrange_gapplessgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai)
{ {
int i, cols, rows, cn, rn, cc; // counters int i, cols, rows, ch, cw, cn, rn, cc, rrest, crest; // counters
Client *c; Client *c;
/* grid dimensions */ /* grid dimensions */
@ -437,22 +437,31 @@ arrange_gapplessgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int
if (an == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ if (an == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
cols = 2; cols = 2;
rows = an/cols; rows = an/cols;
cn = rn = cc = 0; // reset cell no, row no, client count cn = rn = cc = 0; // reset column no, row no, client count
ch = (h - ih * (rows - 1)) / rows;
rrest = (h - ih * (rows - 1)) - ch * rows;
cw = (w - iv * (cols - 1)) / cols;
crest = (w - iv * (cols - 1)) - cw * cols;
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++) {
if (i >= ai && i < (ai + an)) { if (i >= ai && i < (ai + an)) {
if (cc/rows + 1 > cols - an%cols) if (cc/rows + 1 > cols - an%cols) {
rows = an/cols + 1; rows = an/cols + 1;
ch = (h - ih * (rows - 1)) / rows;
rrest = (h - ih * (rows - 1)) - ch * rows;
}
resize(c, resize(c,
x + cn*((w - iv*(cols - 1)) / cols + iv), x,
y + rn*((h - ih*(rows - 1)) / rows + ih), y + rn*(ch + ih) + MIN(rn, rrest),
(w - iv*(cols - 1)) / cols, cw + (cn < crest ? 1 : 0) - 2*c->bw,
(h - ih*(rows - 1)) / rows, ch + (rn < rrest ? 1 : 0) - 2*c->bw,
0); 0);
rn++; rn++;
cc++; cc++;
if (rn >= rows) { if (rn >= rows) {
rn = 0; rn = 0;
x += cw + ih + (cn < crest ? 1 : 0);
cn++; cn++;
} }
} }