dwm-flexipatch/patch/pertag.c
bakkeby f45acf8795 Added alttagsdecoration patch.
Unified tag icon handling while adding support for different icons per monitor.

In general LENGTH(tags) has been replaced with a NUMTAGS macro (defaulting to 9)
and the tags[] array has been replaced with a tagicons[][] array, access to which
is done through a single function tagicon.

This allows one central place where alternative tags, alttagsdecoration, or other
future tags logic is handled. This also gives a consistent display of tags
regardless of the module that presents tags.

Additionally the monitor index has been integrated into dwm for easier access.
2020-08-25 16:27:14 +02:00

65 lines
2.4 KiB
C

struct Pertag {
unsigned int curtag, prevtag; /* current and previous tag */
int nmasters[NUMTAGS + 1]; /* number of windows in master area */
#if FLEXTILE_DELUXE_LAYOUT
int nstacks[NUMTAGS + 1]; /* number of windows in primary stack area */
int ltaxis[NUMTAGS + 1][LTAXIS_LAST];
const Layout *ltidxs[NUMTAGS + 1][3]; /* matrix of tags and layouts indexes */
#else
const Layout *ltidxs[NUMTAGS + 1][2]; /* matrix of tags and layouts indexes */
#endif // FLEXTILE_DELUXE_LAYOUT
float mfacts[NUMTAGS + 1]; /* mfacts per tag */
unsigned int sellts[NUMTAGS + 1]; /* selected layouts */
#if PERTAGBAR_PATCH
int showbars[NUMTAGS + 1]; /* display bar for the current tag */
#endif // PERTAGBAR_PATCH
#if SWAPFOCUS_PATCH
Client *prevclient[NUMTAGS + 1];
#endif // SWAPFOCUS_PATCH
#if ZOOMSWAP_PATCH
Client *prevzooms[NUMTAGS + 1]; /* store zoom information */
#endif // ZOOMSWAP_PATCH
#if VANITYGAPS_PATCH
int enablegaps[NUMTAGS + 1];
#endif // VANITYGAPS_PATCH
};
void
pertagview(const Arg *arg)
{
int i;
unsigned int tmptag;
if (arg->ui & TAGMASK) {
selmon->pertag->prevtag = selmon->pertag->curtag;
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
if (arg->ui == ~0)
selmon->pertag->curtag = 0;
else {
for (i = 0; !(arg->ui & 1 << i); i++) ;
selmon->pertag->curtag = i + 1;
}
} else {
tmptag = selmon->pertag->prevtag;
selmon->pertag->prevtag = selmon->pertag->curtag;
selmon->pertag->curtag = tmptag;
}
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
#if FLEXTILE_DELUXE_LAYOUT
selmon->nstack = selmon->pertag->nstacks[selmon->pertag->curtag];
#endif // FLEXTILE_DELUXE_LAYOUT
selmon->mfact = selmon->pertag->mfacts[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];
#if FLEXTILE_DELUXE_LAYOUT
selmon->ltaxis[LAYOUT] = selmon->pertag->ltaxis[selmon->pertag->curtag][LAYOUT];
selmon->ltaxis[MASTER] = selmon->pertag->ltaxis[selmon->pertag->curtag][MASTER];
selmon->ltaxis[STACK] = selmon->pertag->ltaxis[selmon->pertag->curtag][STACK];
selmon->ltaxis[STACK2] = selmon->pertag->ltaxis[selmon->pertag->curtag][STACK2];
#endif // FLEXTILE_DELUXE_LAYOUT
#if PERTAGBAR_PATCH
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
togglebar(NULL);
#endif // PERTAGBAR_PATCH
}