sites

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

dwm-clientspertag-5.6.1.diff (2205B)


      1 diff -ru dwm-5.6.1/dwm.c dwm-5.6.1-cpt/dwm.c
      2 --- dwm-5.6.1/dwm.c	2009-07-26 15:01:50.000000000 +0200
      3 +++ dwm-5.6.1-cpt/dwm.c	2009-09-13 18:08:50.000000000 +0200
      4 @@ -268,12 +268,23 @@
      5  static Window root;
      6  
      7  /* configuration, allows nested code to access above variables */
      8 +static int cpt = -1;
      9 +static void clientspertag(const Arg *arg) {
     10 +	const char *cmd = (const char *)arg->v;
     11 +	if (cmd[0]=='^') {
     12 +		if (cpt==-1) cpt = atoi(cmd+1);
     13 +		else if (cpt==atoi(cmd+1)) cpt = -1;
     14 +		else cpt = atoi(cmd+1);
     15 +	} else cpt = atoi(cmd);
     16 +	arrange();
     17 +}
     18  #include "config.h"
     19  
     20  /* compile-time check if all tags fit into an unsigned int bit array. */
     21  struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
     22  
     23  /* function implementations */
     24 +
     25  void
     26  applyrules(Client *c) {
     27  	const char *class, *instance;
     28 @@ -674,7 +685,7 @@
     29  		drawtext(m->lt[m->sellt]->symbol, dc.norm, False);
     30  		dc.x += dc.w;
     31  	}
     32 -	snprintf(ntext, sizeof ntext, "%u", n);
     33 +	snprintf(ntext, sizeof ntext, "%d/%u", cpt, n);
     34  	dc.w = TEXTW(ntext);
     35  	drawtext(ntext, dc.norm, False);
     36  	x = (dc.x += dc.w);
     37 @@ -1435,6 +1446,7 @@
     38  	sw = DisplayWidth(dpy, screen);
     39  	sh = DisplayHeight(dpy, screen);
     40  	bh = dc.h = dc.font.height + 2;
     41 +	cpt = -1;
     42  	updategeom();
     43  	/* init atoms */
     44  	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
     45 @@ -1549,6 +1561,7 @@
     46  	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     47  	if(n == 0)
     48  		return;
     49 +	if (cpt!=-1 && n>cpt) n = cpt;
     50  	/* master */
     51  	c = nexttiled(m->clients);
     52  	mw = m->mfact * m->ww;
     53 @@ -1563,10 +1576,15 @@
     54  	if(h < bh)
     55  		h = m->wh;
     56  	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
     57 -		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
     58 -		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
     59 -		if(h != m->wh)
     60 -			y = c->y + HEIGHT(c);
     61 +		if (cpt!=-1 && i>=cpt) {
     62 +			resize(c, x, m->wy, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
     63 +			       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
     64 +		} else {
     65 +			resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
     66 +			       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
     67 +			if(h != m->wh)
     68 +				y = c->y + HEIGHT(c);
     69 +		}
     70  	}
     71  }