sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-hide_vacant_tags-6.1.diff (1175B)


      1 diff --git a/dwm.c b/dwm.c
      2 index 0362114..0da6e27 100644
      3 --- a/dwm.c
      4 +++ b/dwm.c
      5 @@ -430,9 +430,15 @@ buttonpress(XEvent *e)
      6  	}
      7  	if (ev->window == selmon->barwin) {
      8  		i = x = 0;
      9 -		do
     10 +		unsigned int occ = 0;
     11 +		for(c = m->clients; c; c = c->next)
     12 +			occ |= c->tags;
     13 +		do {
     14 +			/* do not reserve space for vacant tags */
     15 +			if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
     16 +				continue;
     17  			x += TEXTW(tags[i]);
     18 -		while (ev->x >= x && ++i < LENGTH(tags));
     19 +		} while (ev->x >= x && ++i < LENGTH(tags));
     20  		if (i < LENGTH(tags)) {
     21  			click = ClkTagBar;
     22  			arg.ui = 1 << i;
     23 @@ -717,11 +723,14 @@ drawbar(Monitor *m)
     24  	}
     25  	x = 0;
     26  	for (i = 0; i < LENGTH(tags); i++) {
     27 +		/* do not draw vacant tags */
     28 +		if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
     29 +			continue;
     30  		w = TEXTW(tags[i]);
     31  		drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &scheme[SchemeSel] : &scheme[SchemeNorm]);
     32  		drw_text(drw, x, 0, w, bh, tags[i], urg & 1 << i);
     33  		drw_rect(drw, x + 1, 1, dx, dx, m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
     34 -		           occ & 1 << i, urg & 1 << i);
     35 +		           0, urg & 1 << i);
     36  		x += w;
     37  	}
     38  	w = blw = TEXTW(m->ltsymbol);