sites

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

togglebartag-20230421-e81f17d.diff (2442B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 9efa774..6e005df 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -65,6 +65,7 @@ static const Key keys[] = {
      6  	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
      7  	{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
      8  	{ MODKEY,                       XK_b,      togglebar,      {0} },
      9 +	{ MODKEY|ShiftMask,             XK_b,      togglebar,      {.i = 1} },
     10  	{ MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
     11  	{ MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
     12  	{ MODKEY,                       XK_i,      incnmaster,     {.i = +1 } },
     13 diff --git a/dwm.c b/dwm.c
     14 index f1d86b2..2da996f 100644
     15 --- a/dwm.c
     16 +++ b/dwm.c
     17 @@ -123,6 +123,7 @@ struct Monitor {
     18  	unsigned int sellt;
     19  	unsigned int tagset[2];
     20  	int showbar;
     21 +	unsigned int barmask;
     22  	int topbar;
     23  	Client *clients;
     24  	Client *sel;
     25 @@ -640,6 +641,7 @@ createmon(void)
     26  	m->mfact = mfact;
     27  	m->nmaster = nmaster;
     28  	m->showbar = showbar;
     29 +	m->barmask = showbar * TAGMASK;
     30  	m->topbar = topbar;
     31  	m->lt[0] = &layouts[0];
     32  	m->lt[1] = &layouts[1 % LENGTH(layouts)];
     33 @@ -704,7 +706,7 @@ drawbar(Monitor *m)
     34  	unsigned int i, occ = 0, urg = 0;
     35  	Client *c;
     36  
     37 -	if (!m->showbar)
     38 +	if (!(m->tagset[m->seltags] & m->barmask))
     39  		return;
     40  
     41  	/* draw status first so it can be overdrawn by tags later */
     42 @@ -1715,7 +1717,16 @@ tile(Monitor *m)
     43  void
     44  togglebar(const Arg *arg)
     45  {
     46 -	selmon->showbar = !selmon->showbar;
     47 +	unsigned int ctag = selmon->tagset[selmon->seltags];
     48 +
     49 +	if(arg->i == 1 || ctag == TAGMASK){
     50 +	    selmon->showbar = !selmon->showbar;
     51 +	    selmon->barmask = selmon->showbar * TAGMASK;
     52 +	}
     53 +	else {
     54 +	    selmon->barmask ^= ctag;
     55 +	}
     56  	updatebarpos(selmon);
     57  	XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
     58  	arrange(selmon);
     59 @@ -1842,7 +1853,7 @@ updatebarpos(Monitor *m)
     60  {
     61  	m->wy = m->my;
     62  	m->wh = m->mh;
     63 -	if (m->showbar) {
     64 +	if ((m->tagset[m->seltags] & m->barmask)) {
     65  		m->wh -= bh;
     66  		m->by = m->topbar ? m->wy : m->wy + m->wh;
     67  		m->wy = m->topbar ? m->wy + bh : m->wy;
     68 @@ -2058,6 +2069,10 @@ view(const Arg *arg)
     69  	selmon->seltags ^= 1; /* toggle sel tagset */
     70  	if (arg->ui & TAGMASK)
     71  		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
     72 +	updatebarpos(selmon);
     73 +	XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
     74  	focus(NULL);
     75  	arrange(selmon);
     76  }