dwm-6.0-pertag_without_bar.diff (5578B)
1 Author: Jan Christoph Ebersbach <jceb@e-jc.de>, 2 Troy Sankey <sankeytms@gmail.com> 3 This modified pertag patch keeps the bar static. It is based on Jan 4 Christoph Ebersbach's dwm-pertag-6.0.diff. 5 6 diff --git a/dwm.c b/dwm.c 7 index 1d78655..bd0a7d9 100644 8 --- a/dwm.c 9 +++ b/dwm.c 10 @@ -124,6 +124,7 @@ typedef struct { 11 void (*arrange)(Monitor *); 12 } Layout; 13 14 +typedef struct Pertag Pertag; 15 struct Monitor { 16 char ltsymbol[16]; 17 float mfact; 18 @@ -143,6 +144,7 @@ struct Monitor { 19 Monitor *next; 20 Window barwin; 21 const Layout *lt[2]; 22 + Pertag *pertag; 23 }; 24 25 typedef struct { 26 @@ -287,6 +289,14 @@ static Window root; 27 /* configuration, allows nested code to access above variables */ 28 #include "config.h" 29 30 +struct Pertag { 31 + unsigned int curtag, prevtag; /* current and previous tag */ 32 + int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */ 33 + float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */ 34 + unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */ 35 + const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */ 36 +}; 37 + 38 /* compile-time check if all tags fit into an unsigned int bit array. */ 39 struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; 40 41 @@ -646,6 +656,7 @@ configurerequest(XEvent *e) { 42 Monitor * 43 createmon(void) { 44 Monitor *m; 45 + int i; 46 47 if(!(m = (Monitor *)calloc(1, sizeof(Monitor)))) 48 die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); 49 @@ -657,6 +668,21 @@ createmon(void) { 50 m->lt[0] = &layouts[0]; 51 m->lt[1] = &layouts[1 % LENGTH(layouts)]; 52 strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); 53 + if(!(m->pertag = (Pertag *)calloc(1, sizeof(Pertag)))) 54 + die("fatal: could not malloc() %u bytes\n", sizeof(Pertag)); 55 + m->pertag->curtag = m->pertag->prevtag = 1; 56 + for(i=0; i <= LENGTH(tags); i++) { 57 + /* init nmaster */ 58 + m->pertag->nmasters[i] = m->nmaster; 59 + 60 + /* init mfacts */ 61 + m->pertag->mfacts[i] = m->mfact; 62 + 63 + /* init layouts */ 64 + m->pertag->ltidxs[i][0] = m->lt[0]; 65 + m->pertag->ltidxs[i][1] = m->lt[1]; 66 + m->pertag->sellts[i] = m->sellt; 67 + } 68 return m; 69 } 70 71 @@ -1028,7 +1054,7 @@ grabkeys(void) { 72 73 void 74 incnmaster(const Arg *arg) { 75 - selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); 76 + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0); 77 arrange(selmon); 78 } 79 80 @@ -1555,10 +1581,13 @@ setfullscreen(Client *c, Bool fullscreen) { 81 82 void 83 setlayout(const Arg *arg) { 84 - if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) 85 - selmon->sellt ^= 1; 86 + if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) { 87 + selmon->pertag->sellts[selmon->pertag->curtag] ^= 1; 88 + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; 89 + } 90 if(arg && arg->v) 91 - selmon->lt[selmon->sellt] = (Layout *)arg->v; 92 + selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v; 93 + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; 94 strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); 95 if(selmon->sel) 96 arrange(selmon); 97 @@ -1576,7 +1605,7 @@ setmfact(const Arg *arg) { 98 f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; 99 if(f < 0.1 || f > 0.9) 100 return; 101 - selmon->mfact = f; 102 + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f; 103 arrange(selmon); 104 } 105 106 @@ -1763,9 +1792,27 @@ toggletag(const Arg *arg) { 107 void 108 toggleview(const Arg *arg) { 109 unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); 110 + int i; 111 112 if(newtagset) { 113 + if(newtagset == ~0) { 114 + selmon->pertag->prevtag = selmon->pertag->curtag; 115 + selmon->pertag->curtag = 0; 116 + } 117 + /* test if the user did not select the same tag */ 118 + if(!(newtagset & 1 << (selmon->pertag->curtag - 1))) { 119 + selmon->pertag->prevtag = selmon->pertag->curtag; 120 + for (i=0; !(newtagset & 1 << i); i++) ; 121 + selmon->pertag->curtag = i + 1; 122 + } 123 selmon->tagset[selmon->seltags] = newtagset; 124 + 125 + /* apply settings for this view */ 126 + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; 127 + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; 128 + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; 129 + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; 130 + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; 131 focus(NULL); 132 arrange(selmon); 133 } 134 @@ -2043,11 +2090,31 @@ updatewmhints(Client *c) { 135 136 void 137 view(const Arg *arg) { 138 + int i; 139 + unsigned int tmptag; 140 + 141 if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) 142 return; 143 selmon->seltags ^= 1; /* toggle sel tagset */ 144 - if(arg->ui & TAGMASK) 145 + if(arg->ui & TAGMASK) { 146 + selmon->pertag->prevtag = selmon->pertag->curtag; 147 selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; 148 + if(arg->ui == ~0) 149 + selmon->pertag->curtag = 0; 150 + else { 151 + for (i=0; !(arg->ui & 1 << i); i++) ; 152 + selmon->pertag->curtag = i + 1; 153 + } 154 + } else { 155 + tmptag = selmon->pertag->prevtag; 156 + selmon->pertag->prevtag = selmon->pertag->curtag; 157 + selmon->pertag->curtag = tmptag; 158 + } 159 + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; 160 + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; 161 + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; 162 + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; 163 + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; 164 focus(NULL); 165 arrange(selmon); 166 }