-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-dwm-6.0-pertag2.diff
265 lines (248 loc) · 7.45 KB
/
01-dwm-6.0-pertag2.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
Homepage: http://hg.punctweb.ro
--- a/dwm.c 2012-12-09 20:11:11.000000000 +0200
+++ b/dwm.c 2013-02-11 22:11:39.078773234 +0200
@@ -127,8 +127,6 @@ typedef struct {
struct Monitor {
char ltsymbol[16];
- float mfact;
- int nmaster;
int num;
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
@@ -144,9 +142,21 @@ struct Monitor {
Monitor *next;
Window barwin;
const Layout *lt[2];
+ int curtag;
+ int prevtag;
+ const Layout **lts;
+ double *mfacts;
+ int *nmasters;
};
typedef struct {
+ const char *name;
+ const Layout *layout;
+ float mfact;
+ int nmaster;
+} Tag;
+
+typedef struct {
const char *class;
const char *instance;
const char *title;
@@ -252,6 +262,7 @@ static int xerror(Display *dpy, XErrorEv
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
+static void bstack(Monitor *m);
/* variables */
static const char broken[] = "broken";
@@ -442,7 +453,7 @@ buttonpress(XEvent *e) {
if(ev->window == selmon->barwin) {
i = x = 0;
do
- x += TEXTW(tags[i]);
+ x += TEXTW(tags[i].name);
while(ev->x >= x && ++i < LENGTH(tags));
if(i < LENGTH(tags)) {
click = ClkTagBar;
@@ -515,6 +526,9 @@ cleanupmon(Monitor *mon) {
}
XUnmapWindow(dpy, mon->barwin);
XDestroyWindow(dpy, mon->barwin);
+ free(mon->mfacts);
+ free(mon->nmasters);
+ free(mon->lts);
free(mon);
}
@@ -534,6 +548,7 @@ void
clientmessage(XEvent *e) {
XClientMessageEvent *cme = &e->xclient;
Client *c = wintoclient(cme->window);
+ unsigned int i;
if(!c)
return;
@@ -546,6 +561,10 @@ clientmessage(XEvent *e) {
if(!ISVISIBLE(c)) {
c->mon->seltags ^= 1;
c->mon->tagset[c->mon->seltags] = c->tags;
+ c->mon->prevtag = c->mon->curtag;
+ for(i=0; !(c->tags & 1 << i); i++);
+ c->mon->curtag = i + 1;
+ c->mon->lt[c->mon->sellt] = c->mon->lts[c->mon->curtag];
}
pop(c);
}
@@ -649,17 +668,31 @@ configurerequest(XEvent *e) {
Monitor *
createmon(void) {
Monitor *m;
+ int i, numtags = LENGTH(tags) + 1;
if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
+ if(!(m->mfacts = calloc(numtags, sizeof(double))))
+ die("fatal: could not malloc() %u bytes\n", sizeof(double) * numtags);
+ if(!(m->nmasters = calloc(numtags, sizeof(int))))
+ die("fatal: could not malloc() %u bytes\n", sizeof(int) * numtags);
+ if(!(m->lts = calloc(numtags, sizeof(Layout *))))
+ die("fatal: could not malloc() %u bytes\n", sizeof(Layout *) * numtags);
m->tagset[0] = m->tagset[1] = 1;
- m->mfact = mfact;
- m->nmaster = nmaster;
+ m->mfacts[0] = mfact;
+ m->nmasters[0] = nmaster;
+ m->lts[0] = &layouts[0];
m->showbar = showbar;
m->topbar = topbar;
- m->lt[0] = &layouts[0];
+ m->curtag = m->prevtag = 1;
+ for(i = 1; i < numtags; i++) {
+ m->mfacts[i] = tags[i - 1].mfact < 0 ? mfact : tags[i - 1].mfact;
+ m->nmasters[i] = tags[i - 1].nmaster < 0 ? nmaster : tags[i - 1].nmaster;
+ m->lts[i] = tags[i - 1].layout;
+ }
+ m->lt[0] = m->lts[m->curtag];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
- strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+ strncpy(m->ltsymbol, m->lt[0]->symbol, sizeof m->ltsymbol);
return m;
}
@@ -722,9 +755,9 @@ drawbar(Monitor *m) {
}
dc.x = 0;
for(i = 0; i < LENGTH(tags); i++) {
- dc.w = TEXTW(tags[i]);
+ dc.w = TEXTW(tags[i].name);
col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
- drawtext(tags[i], col, urg & 1 << i);
+ drawtext(tags[i].name, col, urg & 1 << i);
drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
occ & 1 << i, urg & 1 << i, col);
dc.x += dc.w;
@@ -1024,7 +1057,7 @@ grabkeys(void) {
void
incnmaster(const Arg *arg) {
- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
+ selmon->nmasters[selmon->curtag] = MAX(selmon->nmasters[selmon->curtag] + arg->i, 0);
arrange(selmon);
}
@@ -1565,7 +1598,7 @@ setlayout(const Arg *arg) {
if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if(arg && arg->v)
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if(selmon->sel)
arrange(selmon);
@@ -1580,10 +1613,10 @@ setmfact(const Arg *arg) {
if(!arg || !selmon->lt[selmon->sellt]->arrange)
return;
- f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
+ f = arg->f < 1.0 ? arg->f + selmon->mfacts[selmon->curtag] : arg->f - 1.0;
if(f < 0.1 || f > 0.9)
return;
- selmon->mfact = f;
+ selmon->mfacts[selmon->curtag] = f;
arrange(selmon);
}
@@ -1719,13 +1752,13 @@ tile(Monitor *m) {
if(n == 0)
return;
- if(n > m->nmaster)
- mw = m->nmaster ? m->ww * m->mfact : 0;
+ if(n > m->nmasters[m->curtag])
+ mw = m->nmasters[m->curtag] ? m->ww * m->mfacts[m->curtag] : 0;
else
mw = m->ww;
for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
- if(i < m->nmaster) {
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
+ if(i < m->nmasters[m->curtag]) {
+ h = (m->wh - my) / (MIN(n, m->nmasters[m->curtag]) - i);
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
my += HEIGHT(c);
}
@@ -1759,13 +1792,24 @@ togglefloating(const Arg *arg) {
void
toggletag(const Arg *arg) {
- unsigned int newtags;
+ unsigned int i, newtags;
if(!selmon->sel)
return;
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
if(newtags) {
selmon->sel->tags = newtags;
+ if(newtags == ~0) {
+ selmon->prevtag = selmon->curtag;
+ selmon->curtag = 0;
+ }
+ if(!(newtags & 1 << (selmon->curtag - 1))) {
+ selmon->prevtag = selmon->curtag;
+ for(i=0; !(newtags & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ selmon->sel->tags = newtags;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
focus(NULL);
arrange(selmon);
}
@@ -2071,11 +2115,26 @@ updatewmhints(Client *c) {
void
view(const Arg *arg) {
+ unsigned int i;
+
if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
- if(arg->ui & TAGMASK)
+ if(arg->ui & TAGMASK) {
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ selmon->prevtag = selmon->curtag;
+ if(arg->ui == ~0)
+ selmon->curtag = 0;
+ else {
+ for(i=0; !(arg->ui & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ } else {
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ selmon->curtag^= selmon->prevtag;
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ }
+ selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
focus(NULL);
arrange(selmon);
}
@@ -2154,6 +2213,32 @@ zoom(const Arg *arg) {
pop(c);
}
+void
+bstack(Monitor *m) {
+ unsigned int i, n, w, mh, mx, tx;
+ Client *c;
+
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if(n == 0)
+ return;
+
+ if(n > m->nmasters[m->curtag])
+ mh = m->nmasters[m->curtag] ? m->wh * m->mfacts[m->curtag] : 0;
+ else
+ mh = m->wh;
+ for(i = mx = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if(i < m->nmasters[m->curtag]) {
+ w = (m->ww - mx) / (MIN(n, m->nmasters[m->curtag]) - i);
+ resize(c, m->wx + mx, m->wy, w - (2*c->bw), mh - (2*c->bw), False);
+ mx += WIDTH(c);
+ }
+ else {
+ w = (m->ww - tx) / (n - i);
+ resize(c, m->wx + tx, m->wy + mh, w - (2*c->bw), m->wh - mh - (2*c->bw), False);
+ tx += WIDTH(c);
+ }
+}
+
int
main(int argc, char *argv[]) {
if(argc == 2 && !strcmp("-v", argv[1]))