make smfact compatible with pertag

This commit is contained in:
Jakub 2024-05-15 16:23:06 -04:00
parent c88efa050f
commit 7ffccdd3c9

13
dwm.c
View File

@ -334,6 +334,7 @@ struct Pertag {
unsigned int curtag, prevtag; /* current and previous tag */
int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
float smfacts[LENGTH(tags) + 1]; /* smfacts per tag */
unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
@ -799,6 +800,7 @@ createmon(void)
for (i = 0; i <= LENGTH(tags); i++) {
m->pertag->nmasters[i] = m->nmaster;
m->pertag->mfacts[i] = m->mfact;
m->pertag->smfacts[i] = m->smfact;
m->pertag->ltidxs[i][0] = m->lt[0];
m->pertag->ltidxs[i][1] = m->lt[1];
@ -1959,6 +1961,7 @@ setmfact(const Arg *arg)
void
setsmfact(const Arg *arg) {
float sf;
unsigned int i;
if(!arg || !selmon->lt[selmon->sellt]->arrange)
return;
@ -1966,6 +1969,14 @@ setsmfact(const Arg *arg) {
if(sf < 0 || sf > 0.9)
return;
selmon->smfact = sf;
for(i=0; i<LENGTH(tags); ++i)
if(selmon->tagset[selmon->seltags] & 1<<i)
selmon->pertag->smfacts[i+1] = sf;
if(selmon->pertag->curtag == 0)
{
selmon->pertag->smfacts[0] = sf;
}
arrange(selmon);
}
@ -2332,6 +2343,7 @@ toggleview(const Arg *arg)
/* apply settings for this view */
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
selmon->smfact = selmon->pertag->smfacts[selmon->pertag->curtag];
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
@ -2729,6 +2741,7 @@ view(const Arg *arg)
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
selmon->smfact = selmon->pertag->smfacts[selmon->pertag->curtag];
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];