about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c4
-rw-r--r--draw.c4
-rw-r--r--dwm.h5
-rw-r--r--event.c8
-rw-r--r--main.c4
-rw-r--r--tag.c40
6 files changed, 48 insertions, 17 deletions
diff --git a/client.c b/client.c
index 9710989..5be438e 100644
--- a/client.c
+++ b/client.c
@@ -24,7 +24,7 @@ resizetitle(Client *c)
 		c->tw = c->w + 2;
 	c->tx = c->x + c->w - c->tw + 2;
 	c->ty = c->y;
-	if(c->tags[tsel])
+	if(isvisible(c))
 		XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
 	else
 		XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th);
@@ -276,7 +276,7 @@ manage(Window w, XWindowAttributes *wa)
 	/* mapping the window now prevents flicker */
 	XMapRaised(dpy, c->win);
 	XMapRaised(dpy, c->title);
-	if(c->tags[tsel])
+	if(isvisible(c))
 		focus(c);
 }
 
diff --git a/draw.c b/draw.c
index 6466f41..bdbe85a 100644
--- a/draw.c
+++ b/draw.c
@@ -109,9 +109,9 @@ drawstatus()
 		dc.x += dc.w;
 		dc.w = textw(tags[i]);
 		if(istile)
-			drawtext(tags[i], (i == tsel));
+			drawtext(tags[i], tsel[i]);
 		else
-			drawtext(tags[i], (i != tsel));
+			drawtext(tags[i], !tsel[i]);
 	}
 	x = dc.x + dc.w;
 	dc.w = textw(stext);
diff --git a/dwm.h b/dwm.h
index 88640b8..41b1c36 100644
--- a/dwm.h
+++ b/dwm.h
@@ -69,12 +69,12 @@ struct Client {
 
 extern const char *tags[];
 extern char stext[1024];
-extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
+extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
 extern unsigned int ntags;
 extern void (*handler[LASTEvent])(XEvent *);
 extern void (*arrange)(Arg *);
 extern Atom wmatom[WMLast], netatom[NetLast];
-extern Bool running, issel;
+extern Bool running, issel, *tsel;
 extern Client *clients, *sel;
 extern Cursor cursor[CurLast];
 extern DC dc;
@@ -121,6 +121,7 @@ extern void appendtag(Arg *arg);
 extern void dofloat(Arg *arg);
 extern void dotile(Arg *arg);
 extern void initrregs();
+extern Bool isvisible(Client *c);
 extern Client *getnext(Client *c);
 extern Client *getprev(Client *c);
 extern void replacetag(Arg *arg);
diff --git a/event.c b/event.c
index 8a1c2a9..05b42f0 100644
--- a/event.c
+++ b/event.c
@@ -108,7 +108,13 @@ buttonpress(XEvent *e)
 			for(a.i = 0; a.i < ntags; a.i++) {
 				x += textw(tags[a.i]);
 				if(ev->x < x) {
-					view(&a);
+					if(ev->button == Button3) {
+						tsel[a.i] = True;
+						arrange(NULL);
+						drawall();
+					}
+					else
+						view(&a);
 					return;
 				}
 			}
diff --git a/main.c b/main.c
index 52c0347..fec7ea8 100644
--- a/main.c
+++ b/main.c
@@ -83,7 +83,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee)
 /* extern */
 
 char stext[1024];
-int tsel = DEFTAG;
+Bool *tsel;
 int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
 unsigned int ntags;
 Atom wmatom[WMLast], netatom[NetLast];
@@ -213,6 +213,8 @@ main(int argc, char *argv[])
 	initrregs();
 
 	for(ntags = 0; tags[ntags]; ntags++);
+	tsel = emallocz(sizeof(Bool) * ntags);
+	tsel[DEFTAG] = True;
 
 	/* style */
 	dc.bg = getcolor(BGCOLOR);
diff --git a/tag.c b/tag.c
index 3aa0263..3e89569 100644
--- a/tag.c
+++ b/tag.c
@@ -51,7 +51,7 @@ dofloat(Arg *arg)
 
 	for(c = clients; c; c = c->next) {
 		c->ismax = False;
-		if(c->tags[tsel]) {
+		if(isvisible(c)) {
 			resize(c, True, TopLeft);
 		}
 		else
@@ -74,7 +74,7 @@ dotile(Arg *arg)
 
 	w = sw - mw;
 	for(n = 0, c = clients; c; c = c->next)
-		if(c->tags[tsel] && !c->isfloat)
+		if(isvisible(c) && !c->isfloat)
 			n++;
 
 	if(n > 1)
@@ -84,7 +84,7 @@ dotile(Arg *arg)
 
 	for(i = 0, c = clients; c; c = c->next) {
 		c->ismax = False;
-		if(c->tags[tsel]) {
+		if(isvisible(c)) {
 			if(c->isfloat) {
 				higher(c);
 				resize(c, True, TopLeft);
@@ -135,14 +135,14 @@ dotile(Arg *arg)
 Client *
 getnext(Client *c)
 {
-	for(; c && !c->tags[tsel]; c = c->next);
+	for(; c && !isvisible(c); c = c->next);
 	return c;
 }
 
 Client *
 getprev(Client *c)
 {
-	for(; c && !c->tags[tsel]; c = c->prev);
+	for(; c && !isvisible(c); c = c->prev);
 	return c;
 }
 
@@ -175,6 +175,17 @@ initrregs()
 	}
 }
 
+Bool
+isvisible(Client *c)
+{
+	unsigned int i;
+
+	for(i = 0; i < ntags; i++)
+		if(c->tags[i] && tsel[i])
+			return True;
+	return False;
+}
+
 void
 replacetag(Arg *arg)
 {
@@ -217,7 +228,8 @@ settags(Client *c)
 			XFree(ch.res_name);
 	}
 	if(!matched)
-		c->tags[tsel] = True;
+		for(i = 0; i < ntags; i++)
+			c->tags[i] = tsel[i];
 }
 
 void
@@ -230,7 +242,11 @@ togglemode(Arg *arg)
 void
 view(Arg *arg)
 {
-	tsel = arg->i;
+	unsigned int i;
+
+	for(i = 0; i < ntags; i++)
+		tsel[i] = False;
+	tsel[arg->i] = True;
 	arrange(NULL);
 	drawall();
 }
@@ -238,13 +254,19 @@ view(Arg *arg)
 void
 viewnext(Arg *arg)
 {
-	arg->i = (tsel < ntags-1) ? tsel+1 : 0;
+	unsigned int i;
+
+	for(i = 0; !tsel[i]; i++);
+	arg->i = (i < ntags-1) ? i+1 : 0;
 	view(arg);
 }
 
 void
 viewprev(Arg *arg)
 {
-	arg->i = (tsel > 0) ? tsel-1 : ntags-1;
+	unsigned int i;
+
+	for(i = 0; !tsel[i]; i++);
+	arg->i = (i > 0) ? i-1 : ntags-1;
 	view(arg);
 }
lass='alt'>
f59ac26b8 ^



053309e60 ^
08f1c6100 ^
053309e60 ^

08f1c6100 ^
3c0a6a896 ^
196ef92c8 ^
08f1c6100 ^
fc47c0edc ^
08f1c6100 ^

004717227 ^

053309e60 ^
346443d1b ^
3c0a6a896 ^
196ef92c8 ^
08f1c6100 ^
fc47c0edc ^
08f1c6100 ^

004717227 ^

08f1c6100 ^



fc47c0edc ^
08f1c6100 ^

fc47c0edc ^

08f1c6100 ^
053309e60 ^



08f1c6100 ^


fc47c0edc ^
08f1c6100 ^

fc47c0edc ^
08f1c6100 ^



fc47c0edc ^
08f1c6100 ^

fc47c0edc ^
08f1c6100 ^


fc47c0edc ^

08f1c6100 ^

4fbba0a65 ^
196ef92c8 ^

adad2d5f4 ^

f59ac26b8 ^


08f1c6100 ^
346443d1b ^
3c0a6a896 ^
196ef92c8 ^



004717227 ^
053309e60 ^
004717227 ^
196ef92c8 ^
053309e60 ^
004717227 ^
053309e60 ^
08f1c6100 ^



a9a5766c6 ^
08f1c6100 ^
a9a5766c6 ^
08f1c6100 ^

a9a5766c6 ^
08f1c6100 ^
afd8ca2f1 ^
3c0a6a896 ^
cdd324d16 ^

afd8ca2f1 ^
004717227 ^
e95f155af ^
afd8ca2f1 ^
004717227 ^
afd8ca2f1 ^
08f1c6100 ^
fc47c0edc ^

a9a5766c6 ^
fc47c0edc ^

a9a5766c6 ^
08f1c6100 ^

3c0a6a896 ^
196ef92c8 ^
053309e60 ^
004717227 ^
053309e60 ^

08f1c6100 ^



a9a5766c6 ^
08f1c6100 ^


3c0a6a896 ^
004717227 ^

053309e60 ^
08f1c6100 ^

cdd324d16 ^


004717227 ^
ecb5a8db9 ^
196ef92c8 ^
08f1c6100 ^
3c0a6a896 ^
196ef92c8 ^



004717227 ^
3c0a6a896 ^

004717227 ^
196ef92c8 ^

196ef92c8 ^
08f1c6100 ^
3c0a6a896 ^
196ef92c8 ^



004717227 ^
196ef92c8 ^

08f1c6100 ^
3c0a6a896 ^
08f1c6100 ^
196ef92c8 ^


004717227 ^



053309e60 ^
08f1c6100 ^
196ef92c8 ^
004717227 ^
053309e60 ^
346443d1b ^
3c0a6a896 ^
eca05d2a3 ^

20661c9c4 ^





4523b29d7 ^
20661c9c4 ^
fc47c0edc ^
20661c9c4 ^




4523b29d7 ^
004717227 ^

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