diff options
| author | bakkeby <[email protected]> | 2020-03-20 15:20:07 +0100 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2020-03-20 15:20:07 +0100 |
| commit | 8047fe257bb95490d5a027a9d3f406f16394108c (patch) | |
| tree | 6904c41307f54373b6c5049903d991ffce77f21e /patch/layout_facts.c | |
| parent | 143f94cbc2d9d6e4a8432677f2af30be70031a9b (diff) | |
| download | dwm-flexipatch-8047fe257bb95490d5a027a9d3f406f16394108c.tar.gz dwm-flexipatch-8047fe257bb95490d5a027a9d3f406f16394108c.zip | |
Layouts - re-distributing remaining pixels after even split to address #12
Diffstat (limited to 'patch/layout_facts.c')
| -rw-r--r-- | patch/layout_facts.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/patch/layout_facts.c b/patch/layout_facts.c new file mode 100644 index 0000000..bc0a97a --- /dev/null +++ b/patch/layout_facts.c @@ -0,0 +1,51 @@ +#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 slave 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 slave 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 slave 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 slave split +} +#endif // CFACTS_PATCH
\ No newline at end of file |
