mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 12:05:45 +00:00
Horizgrid pixel perfect updates
This commit is contained in:
parent
443795e3c9
commit
ac4c5081c5
@ -1,82 +1,104 @@
|
|||||||
#if VANITYGAPS_PATCH
|
|
||||||
void
|
void
|
||||||
horizgrid(Monitor *m) {
|
horizgrid(Monitor *m) {
|
||||||
Client *c;
|
Client *c;
|
||||||
unsigned int n, i;
|
unsigned int n, i;
|
||||||
int w = 0, oh, ov, ih, iv;
|
int mx = 0, my = 0, mh = 0, mw = 0;
|
||||||
int ntop, nbottom = 0;
|
int sx = 0, sy = 0, sh = 0, sw = 0;
|
||||||
|
int ntop, nbottom = 1;
|
||||||
|
float mfacts = 0, sfacts = 0;
|
||||||
|
int mrest, srest, mtotal = 0, stotal = 0;
|
||||||
|
|
||||||
/* Count windows */
|
#if VANITYGAPS_PATCH
|
||||||
|
int oh, ov, ih, iv;
|
||||||
getgaps(m, &oh, &ov, &ih, &iv, &n);
|
getgaps(m, &oh, &ov, &ih, &iv, &n);
|
||||||
|
#else
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
#endif // VANITYGAPS_PATCH
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (n == 1) { /* Just fill the whole screen */
|
if (n <= 2)
|
||||||
c = nexttiled(m->clients);
|
ntop = n;
|
||||||
resize(c, m->wx + ov, m->wy + oh, m->ww - 2*ov - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
|
else {
|
||||||
} else if (n == 2) { /* Split vertically */
|
|
||||||
w = (m->ww - 2*ov - iv) / 2;
|
|
||||||
c = nexttiled(m->clients);
|
|
||||||
resize(c, m->wx + ov, m->wy + oh, w - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
|
|
||||||
c = nexttiled(c->next);
|
|
||||||
resize(c, m->wx + ov + w + iv, m->wy + oh, w - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
|
|
||||||
} else {
|
|
||||||
ntop = n / 2;
|
ntop = n / 2;
|
||||||
nbottom = n - ntop;
|
nbottom = n - ntop;
|
||||||
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
|
||||||
if (i < ntop)
|
|
||||||
resize(
|
|
||||||
c,
|
|
||||||
m->wx + ov + i * ((m->ww - 2*ov - iv*(ntop - 1)) / ntop + iv),
|
|
||||||
m->wy + oh,
|
|
||||||
(m->ww - 2*ov - iv*(ntop - 1)) / ntop - (2*c->bw),
|
|
||||||
(m->wh - 2*oh - ih) / 2 - (2*c->bw),
|
|
||||||
False
|
|
||||||
);
|
|
||||||
else
|
|
||||||
resize(
|
|
||||||
c,
|
|
||||||
m->wx + ov + (i - ntop) * ((m->ww - 2*ov - iv*(nbottom - 1)) / nbottom + iv),
|
|
||||||
m->wy + oh + ih + (m->wh - 2*oh - ih) / 2,
|
|
||||||
(m->ww - 2*ov - iv*(nbottom - 1)) / nbottom - (2*c->bw),
|
|
||||||
(m->wh - 2*oh - ih) / 2 - (2*c->bw),
|
|
||||||
False
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
if (n > ntop) {
|
||||||
|
sh = (mh - ih) / 2;
|
||||||
|
mh = mh - ih - sh;
|
||||||
|
sy = my + mh + ih;
|
||||||
|
mw = m->ww - 2*ov - iv * (ntop - 1);
|
||||||
|
sw = m->ww - 2*ov - iv * (nbottom - 1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void
|
sx = mx = m->wx;
|
||||||
horizgrid(Monitor *m) {
|
sy = my = m->wy;
|
||||||
Client *c;
|
sh = mh = m->wh;
|
||||||
unsigned int n, i;
|
sw = mw = m->ww;
|
||||||
int w = 0;
|
|
||||||
int ntop, nbottom = 0;
|
|
||||||
|
|
||||||
/* Count windows */
|
if (n > ntop) {
|
||||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
sh = mh / 2;
|
||||||
|
mh = mh - sh;
|
||||||
|
sy = my + mh;
|
||||||
|
}
|
||||||
|
#endif // VANITYGAPS_PATCH
|
||||||
|
|
||||||
if (n == 0)
|
/* calculate facts */
|
||||||
return;
|
#if CFACTS_PATCH
|
||||||
else if (n == 1) { /* Just fill the whole screen */
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
c = nexttiled(m->clients);
|
|
||||||
resize(c, m->wx, m->wy, m->ww - (2*c->bw), m->wh - (2*c->bw), False);
|
|
||||||
} else if (n == 2) { /* Split vertically */
|
|
||||||
w = m->ww / 2;
|
|
||||||
c = nexttiled(m->clients);
|
|
||||||
resize(c, m->wx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
|
||||||
c = nexttiled(c->next);
|
|
||||||
resize(c, m->wx + w, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
|
||||||
} else {
|
|
||||||
ntop = n / 2;
|
|
||||||
nbottom = n - ntop;
|
|
||||||
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
|
||||||
if (i < ntop)
|
if (i < ntop)
|
||||||
resize(c, m->wx + i * m->ww / ntop, m->wy, m->ww / ntop - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
mfacts += c->cfact;
|
||||||
else
|
else
|
||||||
resize(c, m->wx + (i - ntop) * m->ww / nbottom, m->wy + m->wh / 2, m->ww / nbottom - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
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;
|
||||||
|
sfacts = nbottom;
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user