sites

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

dwm-pertag-5.2.diff (2859B)


      1 --- dwm-5.2/dwm.c	2008-09-09 21:46:17.000000000 +0200
      2 +++ dwm-5.2-pertag/dwm.c	2008-10-12 23:53:30.000000000 +0200
      3 @@ -240,6 +240,11 @@
      4  /* configuration, allows nested code to access above variables */
      5  #include "config.h"
      6  
      7 +static int curtag = 1, prevtag = 1;
      8 +static Layout *lts[LENGTH(tags) + 1];
      9 +static double mfacts[LENGTH(tags) + 1];
     10 +static Bool showbars[LENGTH(tags) + 1];
     11 +
     12  /* compile-time check if all tags fit into an unsigned int bit array. */
     13  struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
     14  
     15 @@ -1272,7 +1277,7 @@
     16  	if(!arg || !arg->v || arg->v != lt[sellt])
     17  		sellt ^= 1;
     18  	if(arg && arg->v)
     19 -		lt[sellt] = (Layout *)arg->v;
     20 +		lt[sellt] = lts[curtag] = (Layout *)arg->v;
     21  	if(sel)
     22  		arrange();
     23  	else
     24 @@ -1289,7 +1294,7 @@
     25  	f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0;
     26  	if(f < 0.1 || f > 0.9)
     27  		return;
     28 -	mfact = f;
     29 +	mfact = mfacts[curtag] = f;
     30  	arrange();
     31  }
     32  
     33 @@ -1337,12 +1342,27 @@
     34  	if(!dc.font.set)
     35  		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
     36  
     37 +	/* init mfacts */
     38 +	for(i=0; i < LENGTH(tags) + 1 ; i++) {
     39 +		mfacts[i] = mfact;
     40 +	}
     41 +
     42 +	/* init layouts */
     43 +	for(i=0; i < LENGTH(tags) + 1; i++) {
     44 +		lts[i] = &layouts[0];
     45 +	}
     46 +
     47 +
     48  	/* init bar */
     49  	for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
     50  		w = TEXTW(layouts[i].symbol);
     51  		blw = MAX(blw, w);
     52  	}
     53  
     54 +	for(i=0; i < LENGTH(tags) + 1; i++) {
     55 +		showbars[i] = showbar;
     56 + 	}
     57 +
     58  	wa.override_redirect = 1;
     59  	wa.background_pixmap = ParentRelative;
     60  	wa.event_mask = ButtonPressMask|ExposureMask;
     61 @@ -1457,7 +1477,7 @@
     62  
     63  void
     64  togglebar(const Arg *arg) {
     65 -	showbar = !showbar;
     66 +	showbar = showbars[curtag] = !showbar;
     67  	updategeom();
     68  	updatebar();
     69  	arrange();
     70 @@ -1490,9 +1510,23 @@
     71  void
     72  toggleview(const Arg *arg) {
     73  	unsigned int mask = tagset[seltags] ^ (arg->ui & TAGMASK);
     74 +	unsigned int i;
     75  
     76  	if(mask) {
     77 +		if(mask == ~0) {
     78 +			prevtag = curtag;
     79 +			curtag = 0;
     80 +		}
     81 +		if(!(mask & 1 << (curtag - 1))) {
     82 +			prevtag = curtag;
     83 +			for (i=0; !(mask & 1 << i); i++);
     84 +			curtag = i + 1;
     85 +		}
     86  		tagset[seltags] = mask;
     87 +		lt[sellt] = lts[curtag];
     88 +		mfact = mfacts[curtag];
     89 +		if (showbar != showbars[curtag])
     90 +			togglebar(NULL);
     91  		clearurgent();
     92  		arrange();
     93  	}
     94 @@ -1661,11 +1695,28 @@
     95  
     96  void
     97  view(const Arg *arg) {
     98 +    unsigned int i;
     99  	if((arg->ui & TAGMASK) == tagset[seltags])
    100  		return;
    101  	seltags ^= 1; /* toggle sel tagset */
    102 -	if(arg->ui & TAGMASK)
    103 +	if(arg->ui & TAGMASK) {
    104  		tagset[seltags] = arg->ui & TAGMASK;
    105 +		prevtag = curtag;
    106 +		if(arg->ui == ~0)
    107 +			curtag = 0;
    108 +		else {
    109 +			for (i=0; !(arg->ui & 1 << i); i++);
    110 +			curtag = i + 1;
    111 +		}
    112 +	} else {
    113 +		prevtag= curtag ^ prevtag;
    114 +		curtag^= prevtag;
    115 +		prevtag= curtag ^ prevtag;
    116 +	}
    117 +	lt[sellt]= lts[curtag];
    118 +	mfact = mfacts[curtag];
    119 +	if(showbar != showbars[curtag])
    120 +		togglebar(NULL);
    121  	clearurgent();
    122  	arrange();
    123  }