2019-09-09 17:31:16 +00:00
|
|
|
void
|
|
|
|
horizgrid(Monitor *m) {
|
|
|
|
Client *c;
|
|
|
|
unsigned int n, i;
|
2020-05-10 12:58:00 +00:00
|
|
|
int mx = 0, my = 0, mh = 0, mw = 0;
|
|
|
|
int sx = 0, sy = 0, sh = 0, sw = 0;
|
2020-05-13 07:41:44 +00:00
|
|
|
int ntop;
|
2020-05-10 12:58:00 +00:00
|
|
|
float mfacts = 0, sfacts = 0;
|
|
|
|
int mrest, srest, mtotal = 0, stotal = 0;
|
2019-09-09 17:31:16 +00:00
|
|
|
|
2020-05-10 12:58:00 +00:00
|
|
|
#if VANITYGAPS_PATCH
|
|
|
|
int oh, ov, ih, iv;
|
2019-09-09 17:31:16 +00:00
|
|
|
getgaps(m, &oh, &ov, &ih, &iv, &n);
|
2020-05-10 12:58:00 +00:00
|
|
|
#else
|
|
|
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
|
|
|
#endif // VANITYGAPS_PATCH
|
2019-09-09 17:31:16 +00:00
|
|
|
if (n == 0)
|
|
|
|
return;
|
|
|
|
|
2020-05-10 12:58:00 +00:00
|
|
|
if (n <= 2)
|
|
|
|
ntop = n;
|
|
|
|
else {
|
2019-09-09 17:31:16 +00:00
|
|
|
ntop = n / 2;
|
|
|
|
}
|
|
|
|
|
2020-05-10 12:58:00 +00:00
|
|
|
#if VANITYGAPS_PATCH
|
|
|
|
sx = mx = m->wx + ov;
|
|
|
|
sy = my = m->wy + oh;
|
|
|
|
sh = mh = m->wh - 2*oh;
|
|
|
|
sw = mw = m->ww - 2*ov;
|
2019-09-09 17:31:16 +00:00
|
|
|
|
2020-05-10 12:58:00 +00:00
|
|
|
if (n > ntop) {
|
|
|
|
sh = (mh - ih) / 2;
|
|
|
|
mh = mh - ih - sh;
|
|
|
|
sy = my + mh + ih;
|
|
|
|
mw = m->ww - 2*ov - iv * (ntop - 1);
|
2020-05-13 07:41:44 +00:00
|
|
|
sw = m->ww - 2*ov - iv * (n - ntop - 1);
|
2019-09-09 17:31:16 +00:00
|
|
|
}
|
2020-05-10 12:58:00 +00:00
|
|
|
#else
|
|
|
|
sx = mx = m->wx;
|
|
|
|
sy = my = m->wy;
|
|
|
|
sh = mh = m->wh;
|
|
|
|
sw = mw = m->ww;
|
|
|
|
|
|
|
|
if (n > ntop) {
|
|
|
|
sh = mh / 2;
|
|
|
|
mh = mh - sh;
|
|
|
|
sy = my + mh;
|
|
|
|
}
|
|
|
|
#endif // VANITYGAPS_PATCH
|
|
|
|
|
|
|
|
/* calculate facts */
|
|
|
|
#if CFACTS_PATCH
|
|
|
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
|
|
if (i < ntop)
|
|
|
|
mfacts += c->cfact;
|
|
|
|
else
|
|
|
|
sfacts += c->cfact;
|
|
|
|
|
|
|
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
|
|
if (i < ntop)
|
|
|
|
mtotal += mh * (c->cfact / mfacts);
|
|
|
|
else
|
|
|
|
stotal += sw * (c->cfact / sfacts);
|
|
|
|
#else
|
|
|
|
mfacts = ntop;
|
2020-05-13 07:41:44 +00:00
|
|
|
sfacts = n - ntop;
|
2020-05-10 12:58:00 +00:00
|
|
|
|
|
|
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
|
|
if (i < ntop)
|
|
|
|
mtotal += mh / mfacts;
|
|
|
|
else
|
|
|
|
stotal += sw / sfacts;
|
|
|
|
#endif // CFACTS_PATCH
|
|
|
|
|
|
|
|
mrest = mh - mtotal;
|
|
|
|
srest = sw - stotal;
|
|
|
|
|
|
|
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
|
|
if (i < ntop) {
|
|
|
|
#if CFACTS_PATCH
|
|
|
|
resize(c, mx, my, mw * (c->cfact / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
|
|
|
|
#else
|
|
|
|
resize(c, mx, my, mw / mfacts + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
|
|
|
|
#endif // CFACTS_PATCH
|
|
|
|
#if VANITYGAPS_PATCH
|
|
|
|
mx += WIDTH(c) + iv;
|
|
|
|
#else
|
|
|
|
mx += WIDTH(c);
|
|
|
|
#endif // VANITYGAPS_PATCH
|
|
|
|
} else {
|
|
|
|
#if CFACTS_PATCH
|
|
|
|
resize(c, sx, sy, sw * (c->cfact / sfacts) + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
|
|
|
|
#else
|
|
|
|
resize(c, sx, sy, sw / sfacts + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
|
|
|
|
#endif // CFACTS_PATCH
|
|
|
|
#if VANITYGAPS_PATCH
|
|
|
|
sx += WIDTH(c) + iv;
|
|
|
|
#else
|
|
|
|
sx += WIDTH(c);
|
|
|
|
#endif // VANITYGAPS_PATCH
|
|
|
|
}
|
|
|
|
}
|