dwm-flexipatch/patch/bar_tagicons.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

20 lines
654 B
C

char *
tagicon(Monitor *m, int tag)
{
#if BAR_ALTTAGSDECORATION_PATCH
Client *c;
#endif // BAR_ALTTAGSDECORATION_PATCH
int tagindex = tag + NUMTAGS * m->index;
if (tagindex >= LENGTH(tagicons[DEFAULT_TAGS]))
tagindex = tagindex % LENGTH(tagicons[DEFAULT_TAGS]);
#if BAR_ALTTAGSDECORATION_PATCH
for (c = m->clients; c && (!(c->tags & 1 << tag) || HIDDEN(c)); c = c->next);
if (c)
return tagicons[ALT_TAGS_DECORATION][tagindex];
#endif // BAR_ALTTAGSDECORATION_PATCH
#if BAR_ALTERNATIVE_TAGS_PATCH
if (m->alttag)
return tagicons[ALTERNATIVE_TAGS][tagindex];
#endif // BAR_ALTERNATIVE_TAGS_PATCH
return tagicons[DEFAULT_TAGS][tagindex];
}