This repository has been archived by the owner on Jan 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
dwm-6.0-pertag2.diff
245 lines (231 loc) · 6.57 KB
/
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
--- dwm.c.orig 2013-03-26 23:43:26.851249905 +0100
+++ dwm.c 2013-03-26 23:43:42.747916305 +0100
@@ -126,8 +126,6 @@
struct Monitor {
char ltsymbol[16];
- float mfact;
- int nmaster;
int num;
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
@@ -143,9 +141,21 @@
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;
@@ -161,6 +171,7 @@
static void arrangemon(Monitor *m);
static void attach(Client *c);
static void attachstack(Client *c);
+static void bstack(Monitor *m);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
static void cleanup(void);
@@ -424,6 +435,32 @@
}
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);
+ }
+}
+
+void
buttonpress(XEvent *e) {
unsigned int i, x, click;
Arg arg = {0};
@@ -441,7 +478,7 @@
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;
@@ -513,6 +550,9 @@
}
XUnmapWindow(dpy, mon->barwin);
XDestroyWindow(dpy, mon->barwin);
+ free(mon->mfacts);
+ free(mon->nmasters);
+ free(mon->lts);
free(mon);
}
@@ -646,17 +686,31 @@
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;
}
@@ -729,9 +783,9 @@
}
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;
@@ -1028,7 +1082,7 @@
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);
}
@@ -1558,7 +1612,7 @@
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);
@@ -1573,10 +1627,10 @@
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);
}
@@ -1710,13 +1764,13 @@
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);
}
@@ -1748,13 +1802,24 @@
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);
}
@@ -2043,11 +2108,27 @@
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);
}