Fibonacci pixel perfect updates

pull/32/head
bakkeby 4 years ago
parent c65315d52f
commit 1508d9f274

@ -1,14 +1,14 @@
#if VANITYGAPS_PATCH #if VANITYGAPS_PATCH
static void void
fibonacci(Monitor *m, int s) fibonacci(Monitor *m, int s)
{ {
unsigned int i, n; unsigned int i, n;
int nx, ny, nw, nh; int nx, ny, nw, nh;
int oh, ov, ih, iv; int oh, ov, ih, iv;
int nv, hrest = 0, wrest = 0, r = 1;
Client *c; Client *c;
getgaps(m, &oh, &ov, &ih, &iv, &n); getgaps(m, &oh, &ov, &ih, &iv, &n);
if (n == 0) if (n == 0)
return; return;
@ -18,38 +18,63 @@ fibonacci(Monitor *m, int s)
nh = m->wh - 2*oh; nh = m->wh - 2*oh;
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
if ((i % 2 && nh / 2 > 2*c->bw) if (r) {
|| (!(i % 2) && nw / 2 > 2*c->bw)) { if ((i % 2 && (nh - ih) / 2 <= (bh + 2*c->bw))
if (i < n - 1) { || (!(i % 2) && (nw - iv) / 2 <= (bh + 2*c->bw))) {
if (i % 2) r = 0;
nh = (nh - ih) / 2; }
else if (r && i < n - 1) {
nw = (nw - iv) / 2; if (i % 2) {
nv = (nh - ih) / 2;
hrest = nh - 2*nv - ih;
nh = nv;
} else {
nv = (nw - iv) / 2;
wrest = nw - 2*nv - iv;
nw = nv;
}
if ((i % 4) == 2 && !s) if ((i % 4) == 2 && !s)
nx += nw + iv; nx += nw + iv;
else if ((i % 4) == 3 && !s) else if ((i % 4) == 3 && !s)
ny += nh + ih; ny += nh + ih;
} }
if ((i % 4) == 0) { if ((i % 4) == 0) {
if (s) if (s) {
ny += nh + ih; ny += nh + ih;
else nh += hrest;
}
else {
nh -= hrest;
ny -= nh + ih; ny -= nh + ih;
}
} }
else if ((i % 4) == 1) else if ((i % 4) == 1) {
nx += nw + iv; nx += nw + iv;
else if ((i % 4) == 2) nw += wrest;
}
else if ((i % 4) == 2) {
ny += nh + ih; ny += nh + ih;
nh += hrest;
if (i < n - 1)
nw += wrest;
}
else if ((i % 4) == 3) { else if ((i % 4) == 3) {
if (s) if (s) {
nx += nw + iv; nx += nw + iv;
else nw -= wrest;
} else {
nw -= wrest;
nx -= nw + iv; nx -= nw + iv;
nh += hrest;
}
} }
if (i == 0) { if (i == 0) {
if (n != 1) if (n != 1) {
nw = (m->ww - 2*ov - iv) * m->mfact; nw = (m->ww - iv - 2*ov) - (m->ww - iv - 2*ov) * (1 - m->mfact);
wrest = 0;
}
ny = m->wy + oh; ny = m->wy + oh;
} }
else if (i == 1) else if (i == 1)
@ -62,60 +87,88 @@ fibonacci(Monitor *m, int s)
} }
#else #else
void void
fibonacci(Monitor *mon, int s) fibonacci(Monitor *m, int s)
{ {
unsigned int i, n, nx, ny, nw, nh; unsigned int i, n;
int nx, ny, nw, nh;
int nv, hrest = 0, wrest = 0, r = 1;
Client *c; Client *c;
for (n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0) if (n == 0)
return; return;
nx = mon->wx; nx = m->wx;
ny = 0; ny = m->wy;
nw = mon->ww; nw = m->ww;
nh = mon->wh; nh = m->wh;
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
if (r) {
if ((i % 2 && nh / 2 <= (bh + 2*c->bw))
|| (!(i % 2) && nw / 2 <= (bh + 2*c->bw))) {
r = 0;
}
if (r && i < n - 1) {
if (i % 2) {
nv = nh / 2;
hrest = nh - 2*nv;
nh = nv;
} else {
nv = nw / 2;
wrest = nw - 2*nv;
nw = nv;
}
for (i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
if ((i % 2 && nh / 2 > 2 * c->bw)
|| (!(i % 2) && nw / 2 > 2 * c->bw)) {
if (i < n - 1) {
if (i % 2)
nh /= 2;
else
nw /= 2;
if ((i % 4) == 2 && !s) if ((i % 4) == 2 && !s)
nx += nw; nx += nw;
else if ((i % 4) == 3 && !s) else if ((i % 4) == 3 && !s)
ny += nh; ny += nh;
} }
if ((i % 4) == 0) { if ((i % 4) == 0) {
if (s) if (s) {
ny += nh; ny += nh;
else nh += hrest;
}
else {
nh -= hrest;
ny -= nh; ny -= nh;
}
} }
else if ((i % 4) == 1) else if ((i % 4) == 1) {
nx += nw; nx += nw;
else if ((i % 4) == 2) nw += wrest;
}
else if ((i % 4) == 2) {
ny += nh; ny += nh;
nh += hrest;
if (i < n - 1)
nw += wrest;
}
else if ((i % 4) == 3) { else if ((i % 4) == 3) {
if (s) if (s) {
nx += nw; nx += nw;
else nw -= wrest;
} else {
nw -= wrest;
nx -= nw; nx -= nw;
nh += hrest;
}
} }
if (i == 0) if (i == 0) {
{ if (n != 1) {
if (n != 1) nw = m->ww - m->ww * (1 - m->mfact);
nw = mon->ww * mon->mfact; wrest = 0;
ny = mon->wy; }
ny = m->wy;
} }
else if (i == 1) else if (i == 1)
nw = mon->ww - nw; nw = m->ww - nw;
i++; i++;
} }
resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False);
} }
} }
#endif #endif

Loading…
Cancel
Save