dwm-pertag-5.4.diff (3400B)
1 diff -r add6eb26ebaa dwm.c 2 --- a/dwm.c Sat Dec 20 12:02:14 2008 +0000 3 +++ b/dwm.c Sun Dec 21 18:39:14 2008 +0100 4 @@ -240,6 +240,11 @@ static Window root, barwin; 5 static Window root, barwin; 6 /* configuration, allows nested code to access above variables */ 7 #include "config.h" 8 + 9 +static int curtag = 1, prevtag = 1; 10 +static Layout *lts[LENGTH(tags) + 1]; 11 +static double mfacts[LENGTH(tags) + 1]; 12 +static Bool showbars[LENGTH(tags) + 1]; 13 14 /* compile-time check if all tags fit into an unsigned int bit array. */ 15 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; }; 16 @@ -1244,7 +1249,7 @@ setlayout(const Arg *arg) { 17 if(!arg || !arg->v || arg->v != lt[sellt]) 18 sellt ^= 1; 19 if(arg && arg->v) 20 - lt[sellt] = (Layout *)arg->v; 21 + lt[sellt] = lts[curtag] = (Layout *)arg->v; 22 if(sel) 23 arrange(); 24 else 25 @@ -1261,7 +1266,7 @@ setmfact(const Arg *arg) { 26 f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0; 27 if(f < 0.1 || f > 0.9) 28 return; 29 - mfact = f; 30 + mfact = mfacts[curtag] = f; 31 arrange(); 32 } 33 34 @@ -1309,11 +1314,26 @@ setup(void) { 35 if(!dc.font.set) 36 XSetFont(dpy, dc.gc, dc.font.xfont->fid); 37 38 + /* init mfacts */ 39 + for(i=0; i < LENGTH(tags) + 1 ; i++) { 40 + mfacts[i] = mfact; 41 + } 42 + 43 + /* init layouts */ 44 + for(i=0; i < LENGTH(tags) + 1; i++) { 45 + lts[i] = &layouts[0]; 46 + } 47 + 48 + 49 /* init bar */ 50 for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) { 51 w = TEXTW(layouts[i].symbol); 52 blw = MAX(blw, w); 53 } 54 + 55 + for(i=0; i < LENGTH(tags) + 1; i++) { 56 + showbars[i] = showbar; 57 + } 58 59 wa.override_redirect = 1; 60 wa.background_pixmap = ParentRelative; 61 @@ -1434,7 +1454,7 @@ tile(void) { 62 63 void 64 togglebar(const Arg *arg) { 65 - showbar = !showbar; 66 + showbar = showbars[curtag] = !showbar; 67 updategeom(); 68 updatebar(); 69 arrange(); 70 @@ -1467,9 +1487,23 @@ void 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 arrange(); 92 } 93 } 94 @@ -1644,11 +1678,28 @@ updatewmhints(Client *c) { 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 arrange(); 122 } 123