about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-05-14 11:54:30 +0200
committerAnselm R. Garbe <arg@suckless.org>2007-05-14 11:54:30 +0200
commitab3d6a7dfe76d9857f2fc621034359a2a0bf09df (patch)
tree9738e466d2ea2b0e1107084b159f8a1b93f271af
parentc67dbb28e47b03eca0c7faddcf7c9862c41694b7 (diff)
downloaddwm-ab3d6a7dfe76d9857f2fc621034359a2a0bf09df.tar.gz
applied dfenze cleanups, fixed some comments in dwm.h
-rw-r--r--client.c14
-rw-r--r--dwm.h9
-rw-r--r--event.c3
-rw-r--r--layout.c15
4 files changed, 20 insertions, 21 deletions
diff --git a/client.c b/client.c
index 3db14f5..72e5c32 100644
--- a/client.c
+++ b/client.c
@@ -153,6 +153,14 @@ focus(Client *c) {
 }
 
 void
+focustopvisible(void) {
+	Client *c;
+
+	for(c = stack; c && !isvisible(c); c = c->snext);
+	focus(c);
+}
+
+void
 killclient(const char *arg) {
 	XEvent ev;
 
@@ -391,10 +399,8 @@ unmanage(Client *c) {
 	XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
 	detach(c);
 	detachstack(c);
-	if(sel == c) {
-		for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
-		focus(nc);
-	}
+	if(sel == c)
+		focustopvisible();
 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
 	setclientstate(c, WithdrawnState);
 	free(c->tags);
diff --git a/dwm.h b/dwm.h
index 9e4cf45..ed5a304 100644
--- a/dwm.h
+++ b/dwm.h
@@ -100,11 +100,12 @@ void attach(Client *c);			/* attaches c to global client list */
 void configure(Client *c);		/* send synthetic configure event */
 void detach(Client *c);			/* detaches c from global client list */
 void focus(Client *c);			/* focus c, c may be NULL */
-void killclient(const char *arg);		/* kill c nicely */
+void focustopvisible(void);	    /* focus top visible window on stack */
+void killclient(const char *arg);		/* kill sel  nicely */
 void manage(Window w, XWindowAttributes *wa);	/* manage new client */
 void resize(Client *c, int x, int y,
 		int w, int h, Bool sizehints);	/* resize with given coordinates c*/
-void togglefloating(const char *arg);	/* toggles focused client between floating/tiled state */
+void togglefloating(const char *arg);	/* toggles sel between floating/tiled state */
 void updatesizehints(Client *c);		/* update the size hint variables of c */
 void updatetitle(Client *c);		/* update the name of c */
 void unmanage(Client *c);		/* destroy c */
@@ -137,8 +138,8 @@ int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
 void compileregs(void);			/* initialize regexps of rules defined in config.h */
 Bool isvisible(Client *c);		/* returns True if client is visible */
 void settags(Client *c, Client *trans);	/* sets tags of c */
-void tag(const char *arg);		/* tags c with arg's index */
-void toggletag(const char *arg);		/* toggles c tags with arg's index */
+void tag(const char *arg);		/* tags sel with arg's index */
+void toggletag(const char *arg);		/* toggles sel tags with arg's index */
 void toggleview(const char *arg);	/* toggles the tag with arg's index (in)visible */
 void view(const char *arg);		/* views the tag with arg's index */
 
diff --git a/event.c b/event.c
index 12746f6..4c0e4e7 100644
--- a/event.c
+++ b/event.c
@@ -247,8 +247,7 @@ enternotify(XEvent *e) {
 		focus(c);
 	else if(ev->window == root) {
 		selscreen = True;
-		for(c = stack; c && !isvisible(c); c = c->snext);
-		focus(c);
+		focustopvisible();
 	}
 }
 
diff --git a/layout.c b/layout.c
index 259f489..04835a8 100644
--- a/layout.c
+++ b/layout.c
@@ -61,10 +61,8 @@ tile(void) {
 			c->isbanned = True;
 			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
 		}
-	if(!sel || !isvisible(sel)) {
-		for(c = stack; c && !isvisible(c); c = c->snext);
-		focus(c);
-	}
+	if(!sel || !isvisible(sel)) 
+		focustopvisible();
 	restack();
 }
 
@@ -88,10 +86,8 @@ floating(void) {
 			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
 		}
 	}
-	if(!sel || !isvisible(sel)) {
-		for(c = stack; c && !isvisible(c); c = c->snext);
-		focus(c);
-	}
+	if(!sel || !isvisible(sel))
+		focustopvisible();
 	restack();
 }
 
@@ -241,13 +237,10 @@ togglemax(const char *arg) {
 
 void
 zoom(const char *arg) {
-	unsigned int n;
 	Client *c;
 
 	if(!sel || lt->arrange != tile || sel->isfloating)
 		return;
-	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
-		n++;
 	if((c = sel) == nexttiled(clients))
 		if(!(c = nexttiled(c->next)))
 			return;
experimental support for querying the type of expressions within macros' href='/ahoang/Nim/commit/compiler/sem.nim?h=devel&id=2e5265bef54ef260213a2ad6ec417f48571c2824'>2e5265bef ^
d9d82fb0a ^

32d0ac01d ^
c43697b59 ^
7063670a2 ^
a22c1f444 ^
7063670a2 ^
eaeed1f84 ^
c7158af75 ^



eaeed1f84 ^




b595fc834 ^


eaeed1f84 ^
2afadc5c9 ^

adc75d020 ^


2afadc5c9 ^

adc75d020 ^


fa0a327dd ^



af441e607 ^



adc75d020 ^





















eaeed1f84 ^



da190876d ^
5e15dec17 ^


1dd01e589 ^
5e15dec17 ^



da190876d ^
5e15dec17 ^
eaeed1f84 ^






2f066395b ^

b595fc834 ^
2f066395b ^
12bac28d2 ^



b4844a189 ^
12bac28d2 ^
af7c92c00 ^
12bac28d2 ^


e5bd3b5b9 ^
e25474154 ^
42516c008 ^
e25474154 ^
e5bd3b5b9 ^
b595fc834 ^


e5bd3b5b9 ^



b595fc834 ^

e5bd3b5b9 ^

b64eeeb43 ^
071b1e395 ^
2aabae702 ^









e25474154 ^
69997af8e ^



e25474154 ^
a59abdf8e ^
12bac28d2 ^
f7884717c ^
a59abdf8e ^









2aabae702 ^

a59abdf8e ^



69997af8e ^
e25474154 ^
b4844a189 ^
7063670a2 ^
e25474154 ^
4d9a5dc8f ^

2e5265bef ^
a0a8934a4 ^
36e25a684 ^
2e5265bef ^








b4844a189 ^
e25474154 ^
e25474154 ^
032599c15 ^


032599c15 ^

b595fc834 ^




032599c15 ^
b595fc834 ^


032599c15 ^
23c3af80f ^
e25474154 ^
55f8ed245 ^




e25474154 ^
b0c11d3ef ^

55f8ed245 ^
e25474154 ^
36e25a684 ^

b0c11d3ef ^
e25474154 ^
eebee0eff ^
3051c52f5 ^
8d19a93f1 ^
121519301 ^
42d0911d6 ^
623fd8a8a ^
e25474154 ^











36e25a684 ^

244c14db0 ^
e25474154 ^
5b28d0820 ^

7063670a2 ^
55f8ed245 ^
7063670a2 ^
e25474154 ^


5b28d0820 ^
e25474154 ^
b64eeeb43 ^
cb6ad8cb7 ^

244c14db0 ^
cb6ad8cb7 ^
623fd8a8a ^







5b28d0820 ^





087b8621d ^
043921c7a ^
5b28d0820 ^

de338526e ^
623fd8a8a ^
043921c7a ^
087b8621d ^
7e31134ff ^

de338526e ^
5b28d0820 ^
ca637c019 ^
99bcc233c ^
ca637c019 ^
99bcc233c ^
ca637c019 ^
e25474154 ^
7063670a2 ^
7ebaf4489 ^

b0c11d3ef ^

e25474154 ^

a1da1f987 ^

ca637c019 ^
e25474154 ^
623fd8a8a ^
e25474154 ^
091c1b307 ^

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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326