dwm-pertag-5.1.diff (2938B)
1 diff -NrU3 dwm-5.1/dwm.c dwm-5.1.playground-pertag/dwm.c 2 --- dwm-5.1/dwm.c 2008-07-29 20:18:32.000000000 +0200 3 +++ dwm-5.1-pertag/dwm.c 2008-08-01 18:46:49.000000000 +0200 4 @@ -238,6 +238,11 @@ 5 /* configuration, allows nested code to access above variables */ 6 #include "config.h" 7 8 +static int curtag = 1, prevtag = 1; 9 +static Layout *lts[LENGTH(tags) + 1]; 10 +static double mfacts[LENGTH(tags) + 1]; 11 +static Bool showbars[LENGTH(tags) + 1]; 12 + 13 /* compile-time check if all tags fit into an unsigned int bit array. */ 14 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; }; 15 16 @@ -1307,7 +1312,7 @@ 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 @@ -1324,7 +1329,7 @@ 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 @@ -1373,12 +1378,27 @@ 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 wa.event_mask = ButtonPressMask|ExposureMask; 62 @@ -1479,7 +1499,7 @@ 63 64 void 65 togglebar(const Arg *arg) { 66 - showbar = !showbar; 67 + showbar = showbars[curtag] = !showbar; 68 updategeom(); 69 updatebar(); 70 arrange(); 71 @@ -1508,9 +1528,23 @@ 72 void 73 toggleview(const Arg *arg) { 74 unsigned int mask = tagset[seltags] ^ (arg->ui & TAGMASK); 75 + unsigned int i; 76 77 if(mask) { 78 + if(mask == ~0) { 79 + prevtag = curtag; 80 + curtag = 0; 81 + } 82 + if(!(mask & 1 << (curtag - 1))) { 83 + prevtag = curtag; 84 + for (i=0; !(mask & 1 << i); i++); 85 + curtag = i + 1; 86 + } 87 tagset[seltags] = mask; 88 + lt[sellt] = lts[curtag]; 89 + mfact = mfacts[curtag]; 90 + if (showbar != showbars[curtag]) 91 + togglebar(NULL); 92 clearurgent(); 93 arrange(); 94 } 95 @@ -1663,11 +1697,29 @@ 96 97 void 98 view(const Arg *arg) { 99 + unsigned int i; 100 + 101 if(arg && (arg->i & TAGMASK) == tagset[seltags]) 102 return; 103 seltags ^= 1; /* toggle sel tagset */ 104 - if(arg && (arg->ui & TAGMASK)) 105 + if(arg && (arg->ui & TAGMASK)) { 106 tagset[seltags] = arg->i & TAGMASK; 107 + prevtag = curtag; 108 + if(arg->ui == ~0) 109 + curtag = 0; 110 + else { 111 + for (i=0; !(arg->ui & 1 << i); i++); 112 + curtag = i + 1; 113 + } 114 + } else { 115 + prevtag= curtag ^ prevtag; 116 + curtag^= prevtag; 117 + prevtag= curtag ^ prevtag; 118 + } 119 + lt[sellt]= lts[curtag]; 120 + mfact = mfacts[curtag]; 121 + if(showbar != showbars[curtag]) 122 + togglebar(NULL); 123 clearurgent(); 124 arrange(); 125 }