dwm/patch/layout_facts.c

53 lines
1.5 KiB
C
Raw Normal View History

#if CFACTS_PATCH
void
getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr)
{
unsigned int n;
float mfacts = 0, sfacts = 0;
int mtotal = 0, stotal = 0;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++)
if (n < m->nmaster)
mfacts += c->cfact;
else
sfacts += c->cfact;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++)
if (n < m->nmaster)
mtotal += msize * (c->cfact / mfacts);
else
stotal += ssize * (c->cfact / sfacts);
*mf = mfacts; // total factor of master area
2020-03-20 16:18:58 +01:00
*sf = sfacts; // total factor of stack area
*mr = msize - mtotal; // the remainder (rest) of pixels after a cfacts master split
2020-03-20 16:18:58 +01:00
*sr = ssize - stotal; // the remainder (rest) of pixels after a cfacts stack split
}
#else
void
getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr)
{
unsigned int n;
float mfacts, sfacts;
int mtotal = 0, stotal = 0;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
mfacts = MIN(n, m->nmaster);
sfacts = n - m->nmaster;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++)
if (n < m->nmaster)
mtotal += msize / mfacts;
else
stotal += ssize / sfacts;
*mf = mfacts; // total factor of master area
2020-03-20 16:18:58 +01:00
*sf = sfacts; // total factor of stack area
*mr = msize - mtotal; // the remainder (rest) of pixels after an even master split
2020-03-20 16:18:58 +01:00
*sr = ssize - stotal; // the remainder (rest) of pixels after an even stack split
}
2020-03-20 16:18:58 +01:00
#endif // CFACTS_PATCH