Merge branch 'main' of git.bitlab21.com:sam/dwm
This commit is contained in:
commit
d138c1a59c
|
@ -54,6 +54,10 @@ static Sp scratchpads[] = {
|
||||||
};
|
};
|
||||||
/* tagging */
|
/* tagging */
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
|
|
||||||
|
static const char ptagf[] = "[%s %s]"; /* format of a tag label */
|
||||||
|
static const char etagf[] = "[%s]"; /* format of an empty tag */
|
||||||
|
static const int lcaselbl = 0; /* 1 means make tag label lowercase */
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
/* class instance title tags mask isfloating isterminal noswallow monitor */
|
/* class instance title tags mask isfloating isterminal noswallow monitor */
|
||||||
{ "St", NULL, NULL, 0, 0, 1, 0, -1 },
|
{ "St", NULL, NULL, 0, 0, 1, 0, -1 },
|
||||||
|
|
27
dwm.c
27
dwm.c
|
@ -20,6 +20,7 @@
|
||||||
*
|
*
|
||||||
* To understand everything else, start reading main().
|
* To understand everything else, start reading main().
|
||||||
*/
|
*/
|
||||||
|
#include <ctype.h> /* for making tab label lowercase, very tiny standard library */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
@ -339,6 +340,8 @@ struct Pertag {
|
||||||
int gappx[LENGTH(tags) + 1]; /* gaps for each tag */
|
int gappx[LENGTH(tags) + 1]; /* gaps for each tag */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsigned int tagw[LENGTH(tags)];
|
||||||
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
/* 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(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
|
@ -555,7 +558,7 @@ buttonpress(XEvent *e)
|
||||||
/* Do not reserve space for vacant tags */
|
/* Do not reserve space for vacant tags */
|
||||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||||
continue;
|
continue;
|
||||||
x += TEXTW(tags[i]);
|
x += tagw[i];
|
||||||
} while (ev->x >= x && ++i < LENGTH(tags));
|
} while (ev->x >= x && ++i < LENGTH(tags));
|
||||||
if (i < LENGTH(tags)) {
|
if (i < LENGTH(tags)) {
|
||||||
click = ClkTagBar;
|
click = ClkTagBar;
|
||||||
|
@ -848,6 +851,8 @@ drawbar(Monitor *m)
|
||||||
int boxw = drw->fonts->h / 6 + 2;
|
int boxw = drw->fonts->h / 6 + 2;
|
||||||
unsigned int i, occ = 0, urg = 0;
|
unsigned int i, occ = 0, urg = 0;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
char tagdisp[64];
|
||||||
|
char *masterclientontag[LENGTH(tags)];
|
||||||
|
|
||||||
if (!m->showbar)
|
if (!m->showbar)
|
||||||
return;
|
return;
|
||||||
|
@ -859,19 +864,35 @@ drawbar(Monitor *m)
|
||||||
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(tags); i++)
|
||||||
|
masterclientontag[i] = NULL;
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
occ |= c->tags == TAGMASK ? 0 : c->tags;
|
occ |= c->tags == TAGMASK ? 0 : c->tags;
|
||||||
if (c->isurgent)
|
if (c->isurgent)
|
||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
|
for (i = 0; i < LENGTH(tags); i++)
|
||||||
|
if (!masterclientontag[i] && c->tags & (1<<i)) {
|
||||||
|
XClassHint ch = { NULL, NULL };
|
||||||
|
XGetClassHint(dpy, c->win, &ch);
|
||||||
|
masterclientontag[i] = ch.res_class;
|
||||||
|
if (lcaselbl)
|
||||||
|
masterclientontag[i][0] = tolower(masterclientontag[i][0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
x = 0;
|
x = 0;
|
||||||
for (i = 0; i < LENGTH(tags); i++) {
|
for (i = 0; i < LENGTH(tags); i++) {
|
||||||
/* Do not draw vacant tags */
|
/* Do not draw vacant tags */
|
||||||
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||||
continue;
|
continue;
|
||||||
w = TEXTW(tags[i]);
|
if (masterclientontag[i])
|
||||||
|
snprintf(tagdisp, 64, ptagf, tags[i], masterclientontag[i]);
|
||||||
|
else
|
||||||
|
snprintf(tagdisp, 64, etagf, tags[i]);
|
||||||
|
masterclientontag[i] = tagdisp;
|
||||||
|
tagw[i] = w = TEXTW(masterclientontag[i]);
|
||||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]);
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]);
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
drw_text(drw, x, 0, w, bh, lrpad / 2, masterclientontag[i], urg & 1 << i);
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
w = TEXTW(m->ltsymbol);
|
w = TEXTW(m->ltsymbol);
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
diff -pu dwm.hide_vacant_tags/config.def.h dwm.programtags+hidewithvacanttags/config.def.h
|
||||||
|
--- dwm.hide_vacant_tags/config.def.h 2021-03-15 16:37:24.586622415 -0500
|
||||||
|
+++ dwm.programtags+hidewithvacanttags/config.def.h 2021-03-15 16:32:37.586956549 -0500
|
||||||
|
@@ -21,6 +21,10 @@ static const char *colors[][3] = {
|
||||||
|
/* tagging */
|
||||||
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
|
|
||||||
|
+static const char ptagf[] = "[%s %s]"; /* format of a tag label */
|
||||||
|
+static const char etagf[] = "[%s]"; /* format of an empty tag */
|
||||||
|
+static const int lcaselbl = 0; /* 1 means make tag label lowercase */
|
||||||
|
+
|
||||||
|
static const Rule rules[] = {
|
||||||
|
/* xprop(1):
|
||||||
|
* WM_CLASS(STRING) = instance, class
|
||||||
|
diff -pu dwm.hide_vacant_tags/dwm.c dwm.programtags+hidewithvacanttags/dwm.c
|
||||||
|
--- dwm.hide_vacant_tags/dwm.c 2021-03-15 16:37:38.189939908 -0500
|
||||||
|
+++ dwm.programtags+hidewithvacanttags/dwm.c 2021-03-15 16:32:23.693639390 -0500
|
||||||
|
@@ -20,6 +20,7 @@
|
||||||
|
*
|
||||||
|
* To understand everything else, start reading main().
|
||||||
|
*/
|
||||||
|
+#include <ctype.h> /* for making tab label lowercase, very tiny standard library */
|
||||||
|
#include <errno.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <signal.h>
|
||||||
|
@@ -272,6 +273,8 @@ static Window root, wmcheckwin;
|
||||||
|
/* configuration, allows nested code to access above variables */
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
+unsigned int tagw[LENGTH(tags)];
|
||||||
|
+
|
||||||
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
|
@@ -438,7 +441,7 @@ buttonpress(XEvent *e)
|
||||||
|
/* do not reserve space for vacant tags */
|
||||||
|
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||||
|
continue;
|
||||||
|
- x += TEXTW(tags[i]);
|
||||||
|
+ x += tagw[i];
|
||||||
|
} while (ev->x >= x && ++i < LENGTH(tags));
|
||||||
|
if (i < LENGTH(tags)) {
|
||||||
|
click = ClkTagBar;
|
||||||
|
@@ -706,6 +709,8 @@ drawbar(Monitor *m)
|
||||||
|
int boxw = drw->fonts->h / 6 + 2;
|
||||||
|
unsigned int i, occ = 0, urg = 0;
|
||||||
|
Client *c;
|
||||||
|
+ char tagdisp[64];
|
||||||
|
+ char *masterclientontag[LENGTH(tags)];
|
||||||
|
|
||||||
|
/* draw status first so it can be overdrawn by tags later */
|
||||||
|
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||||
|
@@ -714,10 +719,21 @@ drawbar(Monitor *m)
|
||||||
|
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ for (i = 0; i < LENGTH(tags); i++)
|
||||||
|
+ masterclientontag[i] = NULL;
|
||||||
|
+
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
occ |= c->tags == 255 ? 0 : c->tags;
|
||||||
|
if (c->isurgent)
|
||||||
|
urg |= c->tags;
|
||||||
|
+ for (i = 0; i < LENGTH(tags); i++)
|
||||||
|
+ if (!masterclientontag[i] && c->tags & (1<<i)) {
|
||||||
|
+ XClassHint ch = { NULL, NULL };
|
||||||
|
+ XGetClassHint(dpy, c->win, &ch);
|
||||||
|
+ masterclientontag[i] = ch.res_class;
|
||||||
|
+ if (lcaselbl)
|
||||||
|
+ masterclientontag[i][0] = tolower(masterclientontag[i][0]);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
x = 0;
|
||||||
|
for (i = 0; i < LENGTH(tags); i++) {
|
||||||
|
@@ -725,9 +741,14 @@ drawbar(Monitor *m)
|
||||||
|
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
- w = TEXTW(tags[i]);
|
||||||
|
+ if (masterclientontag[i])
|
||||||
|
+ snprintf(tagdisp, 64, ptagf, tags[i], masterclientontag[i]);
|
||||||
|
+ else
|
||||||
|
+ snprintf(tagdisp, 64, etagf, tags[i]);
|
||||||
|
+ masterclientontag[i] = tagdisp;
|
||||||
|
+ tagw[i] = w = TEXTW(masterclientontag[i]);
|
||||||
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||||
|
- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||||
|
+ drw_text(drw, x, 0, w, bh, lrpad / 2, masterclientontag[i], urg & 1 << i);
|
||||||
|
x += w;
|
||||||
|
}
|
||||||
|
w = blw = TEXTW(m->ltsymbol);
|
Loading…
Reference in New Issue