diff options
| author | Bear <bear@bengtsson.win> | 2021-12-27 09:29:58 +0000 |
|---|---|---|
| committer | Bear <bear@bengtsson.win> | 2021-12-27 09:29:58 +0000 |
| commit | 69262b01ced79c2d776fab9b889926d1816a1e7a (patch) | |
| tree | f304cd6fa8734e83a7772d07dc9b484781565155 /patch/layout_facts.c | |
Added DWM
Diffstat (limited to 'patch/layout_facts.c')
| -rw-r--r-- | patch/layout_facts.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/patch/layout_facts.c b/patch/layout_facts.c new file mode 100644 index 0000000..611e89e --- /dev/null +++ b/patch/layout_facts.c @@ -0,0 +1,52 @@ +#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 + *sf = sfacts; // total factor of stack area + *mr = msize - mtotal; // the remainder (rest) of pixels after a cfacts master split + *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 + *sf = sfacts; // total factor of stack area + *mr = msize - mtotal; // the remainder (rest) of pixels after an even master split + *sr = ssize - stotal; // the remainder (rest) of pixels after an even stack split +} +#endif // CFACTS_PATCH + |
