[dwm] Rewrite rearrangebar to be cleaner

This commit is contained in:
dogeystamp 2021-04-15 20:22:31 -04:00
parent 31ae26518b
commit 6f1daa39f8

View File

@ -782,16 +782,20 @@ drawbar(Monitor *m)
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
Client *c;
w = blw = TEXTW(m->ltsymbol);
/* clear bar from last draw */
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, 0, 0, m->ww, bh, lrpad / 2, 1);
if (!m->showbar)
return;
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeNorm]);
tw = TEXTW(stext) - lrpad + TEXTW(m->ltsymbol); /* right padding for ltsymbol */
drw_text(drw, m->ww-m->ww/3, 0, m->ww/3, bh, 0, "", 0);
drw_text(drw, m->ww-tw, 0, m->ww/3, bh, 0, stext, 0);
tw = TEXTW(stext) - lrpad + w; /* right padding for the tiling symbol */
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
drw_text(drw, m->ww - w, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
}
for (c = m->clients; c; c = c->next) {
@ -810,18 +814,13 @@ drawbar(Monitor *m)
urg & 1 << i);
x += w;
}
w = TEXTW(m->ltsymbol);
drw_setscheme(drw, scheme[SchemeNorm]);
drw_text(drw, m->ww-w, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, "", 0);
x = m->ww/3;
if ((w = m->ww - tw - x) > bh) {
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
if(m == selmon)
drw_text(drw, m->ww/2-m->ww/6, 0, m->ww/3, bh, lrpad / 2, m->sel->name, 0);
else
drw_text(drw, x, 0, w, bh, lrpad / 2, "", 0);
drw_text(drw, x, 0, m->ww/3, bh, lrpad / 2, m->sel->name, 0);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {