this should allow us more characters for the tags/layout indicator IF

the text is set through xrdb
This commit is contained in:
speedie 2022-12-18 19:17:22 +01:00
parent c29f3d336d
commit 042a547a7d
2 changed files with 78 additions and 61 deletions

View file

@ -62,8 +62,8 @@
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TAGSLENGTH (LENGTH(tags))
#define TAGMASK ((1 << LENGTH(ftags)) - 1)
#define TAGSLENGTH (LENGTH(ftags))
#define TEXTW(X) (drw_font_getwidth(drw, (X), False) + lrpad)
#define TEXTWM(X) (drw_font_getwidth(drw, (X), True) + lrpad)
#define RIGHTOF(a,b) (a.y_org > b.y_org) || \
@ -961,21 +961,21 @@ static const char *clickstatus[] = { shell, "-c", NULL, NULL }; /* for running c
#include "bar/items.c"
unsigned int tagw[LENGTH(tags)];
unsigned int tagw[LENGTH(ftags)];
struct Pertag {
unsigned int curtag, prevtag; /* current and previous tag */
int mastercounts[LENGTH(tags) + 1]; /* number of windows in master area */
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
int stackcounts[LENGTH(tags) + 1]; /* number of windows in primary stack area */
int ltaxis[LENGTH(tags) + 1][ltaxislast];
const Layout *ltidxs[LENGTH(tags) + 1][3]; /* matrix of tags and layouts indexes */
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
int mastercounts[LENGTH(ftags) + 1]; /* number of windows in master area */
float mfacts[LENGTH(ftags) + 1]; /* mfacts per tag */
unsigned int sellts[LENGTH(ftags) + 1]; /* selected layouts */
int stackcounts[LENGTH(ftags) + 1]; /* number of windows in primary stack area */
int ltaxis[LENGTH(ftags) + 1][ltaxislast];
const Layout *ltidxs[LENGTH(ftags) + 1][3]; /* matrix of tags and layouts indexes */
int showbars[LENGTH(ftags) + 1]; /* display bar for the current tag */
};
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
struct NumTags { char limitexceeded[LENGTH(ftags) > 31 ? -1 : 1]; };
/* speedwm will keep pid's of processes from autostart array and kill them at quit */
static pid_t *autostart_pids;
@ -1497,7 +1497,7 @@ cleanupmon(Monitor *mon)
#if USETAGPREVIEW
size_t i;
for (i = 0; i < LENGTH(tags); i++)
for (i = 0; i < LENGTH(ftags); i++)
if (mon->tagmap[i])
XFreePixmap(dpy, mon->tagmap[i]);
free(mon->tagmap);
@ -1568,8 +1568,8 @@ clientmessage(XEvent *e)
if (c != selmon->sel && !c->isurgent)
seturgent(c, 1);
} else {
for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++);
if (i < LENGTH(tags)) {
for (i = 0; i < LENGTH(ftags) && !((1 << i) & c->tags); i++);
if (i < LENGTH(ftags)) {
const Arg a = {.ui = 1 << i};
selmon = c->mon;
view(&a);
@ -1790,11 +1790,11 @@ createmon(void)
/* layout */
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
m->lt[1] = &layouts[1 % LENGTH(flayouts)];
#if USETAGPREVIEW
/* map our tags */
m->tagmap = ecalloc(LENGTH(tags), sizeof(Pixmap));
m->tagmap = ecalloc(LENGTH(ftags), sizeof(Pixmap));
#endif
#if USESWITCHER
@ -1813,7 +1813,7 @@ createmon(void)
m->pertag->curtag = m->pertag->prevtag = 1;
/* pertag */
for (i = 0; i <= LENGTH(tags); i++) {
for (i = 0; i <= LENGTH(ftags); i++) {
m->pertag->mastercounts[i] = m->mastercount;
m->pertag->stackcounts[i] = m->stackcount;
m->pertag->mfacts[i] = m->mfact;
@ -1860,7 +1860,7 @@ cyclelayout(const Arg *arg) {
if(l != layouts && (l - 1)->symbol)
setlayout(&((Arg) { .v = (l - 1) }));
else
setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
setlayout(&((Arg) { .v = &layouts[LENGTH(flayouts) - 2] }));
}
}
@ -1906,7 +1906,7 @@ detach(Client *c)
{
Client **tc;
for (int i = 1; i < LENGTH(tags); i++)
for (int i = 1; i < LENGTH(ftags); i++)
if (c == c->mon->tagmarked[i])
c->mon->tagmarked[i] = NULL;
@ -4103,7 +4103,7 @@ unsigned int
nexttag(void)
{
unsigned int seltag = selmon->tagset[selmon->seltags];
return seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1;
return seltag == (1 << (LENGTH(ftags) - 1)) ? 1 : seltag << 1;
}
unsigned int
@ -4123,7 +4123,7 @@ nexttag_skip_vacant(void)
} while (c);
do {
seltag = seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1;
seltag = seltag == (1 << (LENGTH(ftags) - 1)) ? 1 : seltag << 1;
} while (!(seltag & usedtags));
return seltag;
@ -4134,7 +4134,7 @@ unsigned int
prevtag(void)
{
unsigned int seltag = selmon->tagset[selmon->seltags];
return seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1;
return seltag == 1 ? (1 << (LENGTH(ftags) - 1)) : seltag >> 1;
}
unsigned int
@ -4153,7 +4153,7 @@ prevtag_skip_vacant(void)
} while (c);
do {
seltag = seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1;
seltag = seltag == 1 ? (1 << (LENGTH(ftags) - 1)) : seltag >> 1;
} while (!(seltag & usedtags));
return seltag;
@ -4557,13 +4557,13 @@ void
reorganizetags(const Arg *arg) {
Client *c;
unsigned int occ, unocc, i;
unsigned int tagdest[LENGTH(tags)];
unsigned int tagdest[LENGTH(ftags)];
occ = 0;
for (c = selmon->clients; c; c = c->next)
occ |= (1 << (ffs(c->tags)-1));
unocc = 0;
for (i = 0; i < LENGTH(tags); ++i) {
for (i = 0; i < LENGTH(ftags); ++i) {
while (unocc < i && (occ & (1 << unocc)))
unocc++;
if (occ & (1 << i)) {
@ -4692,7 +4692,7 @@ run(void)
ipc_handle_socket_epoll_event(events + i);
} else if (ipc_is_client_registered(event_fd)){
if (ipc_handle_client_epoll_event(events + i, mons, &lastselmon, selmon,
LENGTH(tags), layouts, LENGTH(layouts)) < 0) {
LENGTH(ftags), layouts, LENGTH(flayouts)) < 0) {
fprintf(stderr, "Error handling IPC event on fd %d\n", event_fd);
}
} else {
@ -5086,7 +5086,7 @@ setlayoutsafe(const Arg *arg)
const Layout *ltptr = (Layout *)arg->v;
if (ltptr == 0)
setlayout(arg);
for (int i = 0; i < LENGTH(layouts); i++) {
for (int i = 0; i < LENGTH(flayouts); i++) {
if (ltptr == &layouts[i])
setlayout(arg);
}
@ -5211,7 +5211,7 @@ setup(void)
/* init appearance */
scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], alphas[i], 3);
if (LENGTH(tags) > LENGTH(tagsel))
if (LENGTH(ftags) > LENGTH(tagsel))
die("too few color schemes for the tags");
for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
@ -6625,7 +6625,7 @@ takepreview(void)
else
occ |= c->tags == 255 ? 0 : c->tags;
for (i = 0; i < LENGTH(tags); i++) {
for (i = 0; i < LENGTH(ftags); i++) {
/* searching for tags that are occupied && selected */
if (!(occ & 1 << i) || !(selmon->tagset[selmon->seltags] & 1 << i))
continue;

81
text.h
View file

@ -24,38 +24,55 @@ static char *usedtags[] = { text_tag1_used, /* Tag 1 text
text_tag9_used, /* Tag 9 text (used) */
};
/* Length of tags, text inside doesn't matter
* If you're increasing the number of tags, also increase this.
*/
static char *ftags[] = { "aaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbb",
"ccccccccccccccc",
"ddddddddddddddd",
"eeeeeeeeeeeeeee",
"fffffffffffffff",
"ggggggggggggggg",
"hhhhhhhhhhhhhhh",
"iiiiiiiiiiiiiii",
};
/* Same for layouts */
static char *flayouts[] = { "aaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbb",
"ccccccccccccccc",
"ddddddddddddddd",
"eeeeeeeeeeeeeee",
"fffffffffffffff",
"ggggggggggggggg",
"hhhhhhhhhhhhhhh",
"iiiiiiiiiiiiiii",
"jjjjjjjjjjjjjjj",
"kkkkkkkkkkkkkkk",
"mmmmmmmmmmmmmmm",
"nnnnnnnnnnnnnnn",
"ooooooooooooooo",
"ppppppppppppppp",
"qqqqqqqqqqqqqqq",
};
/* Text for layouts */
static Layout layouts[] = {
/* Tiling */
{ text_layout1, tile, { -1, -1, splitvertical, toptobottom, toptobottom, 0, NULL } },
/* Floating */
{ text_layout2, NULL, {0} },
/* Monocle */
{ text_layout3, tile, { -1, -1, nosplit, monocle, monocle, 0, NULL } },
/* Grid */
{ text_layout4, ngrid, {0} },
/* Deck */
{ text_layout5, tile, { -1, -1, splitvertical, toptobottom, monocle, 0, NULL } },
/* Centered Master */
{ text_layout6, tile, { -1, -1, splithorizontal, lefttoright, toptobottom, 0, NULL } },
/* Tatami */
{ text_layout7, tile, { -1, -1, splitvertical, lefttoright, tatami, 0, NULL } },
/* Spiral */
{ text_layout8, tile, { -1, -1, nosplit, spiral, spiral, 0, NULL } },
/* Dwindle */
{ text_layout9, tile, { -1, -1, nosplit, dwindle, dwindle, 0, NULL } },
/* Bottom Stack */
{ text_layout10, tile, { -1, -1, splithorizontal, lefttoright, lefttoright, 0, NULL } },
/* Bottom Stack (Horizontal */
{ text_layout11, tile, { -1, -1, splithorizontal, lefttoright, toptobottom, 0, NULL } },
/* Horizontal Grid */
{ text_layout12, hgrid, {0} },
/* Dynamic Grid */
{ text_layout13, tile, { -1, -1, nosplit, dynamicgrid, dynamicgrid, 0, NULL } },
/* Custom */
{ text_layout14, custom, {0} },
/* Empty */
{ text_layout15, empty, {0} },
/* Reset to layout 1 */
{ NULL, NULL, {0} },
{ text_layout1, tile, { -1, -1, splitvertical, toptobottom, toptobottom, 0, NULL } }, /* Tiling */
{ text_layout2, NULL, {0} }, /* Floating */
{ text_layout3, tile, { -1, -1, nosplit, monocle, monocle, 0, NULL } }, /* Monocle */
{ text_layout4, ngrid, {0} }, /* Grid */
{ text_layout5, tile, { -1, -1, splitvertical, toptobottom, monocle, 0, NULL } }, /* Deck */
{ text_layout6, tile, { -1, -1, splithorizontal, lefttoright, toptobottom, 0, NULL } }, /* Centered Master */
{ text_layout7, tile, { -1, -1, splitvertical, lefttoright, tatami, 0, NULL } }, /* Tatami */
{ text_layout8, tile, { -1, -1, nosplit, spiral, spiral, 0, NULL } }, /* Spiral */
{ text_layout9, tile, { -1, -1, nosplit, dwindle, dwindle, 0, NULL } }, /* Dwindle */
{ text_layout10, tile, { -1, -1, splithorizontal, lefttoright, lefttoright, 0, NULL } }, /* Bottom Stack Vertical */
{ text_layout11, tile, { -1, -1, splithorizontal, lefttoright, toptobottom, 0, NULL } }, /* Bottom Stack Horizontal */
{ text_layout12, hgrid, {0} }, /* Horizontal Grid */
{ text_layout13, tile, { -1, -1, nosplit, dynamicgrid, dynamicgrid, 0, NULL } }, /* Dynamic Grid */
{ text_layout14, custom, {0} }, /* Custom */
{ text_layout15, empty, {0} }, /* Empty */
{ NULL, NULL, {0} }, /* Reset to layout 1 */
};