equal
deleted
inserted
replaced
6 #include <stdio.h> |
6 #include <stdio.h> |
7 |
7 |
8 /* static */ |
8 /* static */ |
9 |
9 |
10 static Client * |
10 static Client * |
11 minclient() |
11 minclient() { |
12 { |
|
13 Client *c, *min; |
12 Client *c, *min; |
14 |
13 |
15 if((clients && clients->isfloat) || arrange == dofloat) |
14 if((clients && clients->isfloat) || arrange == dofloat) |
16 return clients; /* don't touch floating order */ |
15 return clients; /* don't touch floating order */ |
17 for(min = c = clients; c; c = c->next) |
16 for(min = c = clients; c; c = c->next) |
19 min = c; |
18 min = c; |
20 return min; |
19 return min; |
21 } |
20 } |
22 |
21 |
23 static void |
22 static void |
24 reorder() |
23 reorder() { |
25 { |
|
26 Client *c, *newclients, *tail; |
24 Client *c, *newclients, *tail; |
27 |
25 |
28 newclients = tail = NULL; |
26 newclients = tail = NULL; |
29 while((c = minclient())) { |
27 while((c = minclient())) { |
30 detach(c); |
28 detach(c); |
38 } |
36 } |
39 clients = newclients; |
37 clients = newclients; |
40 } |
38 } |
41 |
39 |
42 static Client * |
40 static Client * |
43 nexttiled(Client *c) |
41 nexttiled(Client *c) { |
44 { |
|
45 for(c = getnext(c); c && c->isfloat; c = getnext(c->next)); |
42 for(c = getnext(c); c && c->isfloat; c = getnext(c->next)); |
46 return c; |
43 return c; |
47 } |
44 } |
48 |
45 |
49 /* extern */ |
46 /* extern */ |
50 |
47 |
51 void (*arrange)(Arg *) = DEFMODE; |
48 void (*arrange)(Arg *) = DEFMODE; |
52 |
49 |
53 void |
50 void |
54 detach(Client *c) |
51 detach(Client *c) { |
55 { |
|
56 if(c->prev) |
52 if(c->prev) |
57 c->prev->next = c->next; |
53 c->prev->next = c->next; |
58 if(c->next) |
54 if(c->next) |
59 c->next->prev = c->prev; |
55 c->next->prev = c->prev; |
60 if(c == clients) |
56 if(c == clients) |
61 clients = c->next; |
57 clients = c->next; |
62 c->next = c->prev = NULL; |
58 c->next = c->prev = NULL; |
63 } |
59 } |
64 |
60 |
65 void |
61 void |
66 dofloat(Arg *arg) |
62 dofloat(Arg *arg) { |
67 { |
|
68 Client *c; |
63 Client *c; |
69 |
64 |
70 maximized = False; |
65 maximized = False; |
71 |
66 |
72 for(c = clients; c; c = c->next) { |
67 for(c = clients; c; c = c->next) { |
82 } |
77 } |
83 restack(); |
78 restack(); |
84 } |
79 } |
85 |
80 |
86 void |
81 void |
87 dotile(Arg *arg) |
82 dotile(Arg *arg) { |
88 { |
|
89 int h, i, n, w; |
83 int h, i, n, w; |
90 Client *c; |
84 Client *c; |
91 |
85 |
92 maximized = False; |
86 maximized = False; |
93 |
87 |
146 } |
140 } |
147 restack(); |
141 restack(); |
148 } |
142 } |
149 |
143 |
150 void |
144 void |
151 focusnext(Arg *arg) |
145 focusnext(Arg *arg) { |
152 { |
|
153 Client *c; |
146 Client *c; |
154 |
147 |
155 if(!sel) |
148 if(!sel) |
156 return; |
149 return; |
157 |
150 |
162 restack(); |
155 restack(); |
163 } |
156 } |
164 } |
157 } |
165 |
158 |
166 void |
159 void |
167 focusprev(Arg *arg) |
160 focusprev(Arg *arg) { |
168 { |
|
169 Client *c; |
161 Client *c; |
170 |
162 |
171 if(!sel) |
163 if(!sel) |
172 return; |
164 return; |
173 |
165 |
180 restack(); |
172 restack(); |
181 } |
173 } |
182 } |
174 } |
183 |
175 |
184 Bool |
176 Bool |
185 isvisible(Client *c) |
177 isvisible(Client *c) { |
186 { |
|
187 unsigned int i; |
178 unsigned int i; |
188 |
179 |
189 for(i = 0; i < ntags; i++) |
180 for(i = 0; i < ntags; i++) |
190 if(c->tags[i] && seltag[i]) |
181 if(c->tags[i] && seltag[i]) |
191 return True; |
182 return True; |
192 return False; |
183 return False; |
193 } |
184 } |
194 |
185 |
195 void |
186 void |
196 resizecol(Arg *arg) |
187 resizecol(Arg *arg) { |
197 { |
|
198 unsigned int n; |
188 unsigned int n; |
199 Client *c; |
189 Client *c; |
200 |
190 |
201 for(n = 0, c = clients; c; c = c->next) |
191 for(n = 0, c = clients; c; c = c->next) |
202 if(isvisible(c) && !c->isfloat) |
192 if(isvisible(c) && !c->isfloat) |
216 } |
206 } |
217 arrange(NULL); |
207 arrange(NULL); |
218 } |
208 } |
219 |
209 |
220 void |
210 void |
221 restack() |
211 restack() { |
222 { |
|
223 Client *c; |
212 Client *c; |
224 XEvent ev; |
213 XEvent ev; |
225 |
214 |
226 if(!sel) { |
215 if(!sel) { |
227 drawstatus(); |
216 drawstatus(); |
240 XSync(dpy, False); |
229 XSync(dpy, False); |
241 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
230 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
242 } |
231 } |
243 |
232 |
244 void |
233 void |
245 togglemode(Arg *arg) |
234 togglemode(Arg *arg) { |
246 { |
|
247 arrange = (arrange == dofloat) ? dotile : dofloat; |
235 arrange = (arrange == dofloat) ? dotile : dofloat; |
248 if(sel) |
236 if(sel) |
249 arrange(NULL); |
237 arrange(NULL); |
250 else |
238 else |
251 drawstatus(); |
239 drawstatus(); |
252 } |
240 } |
253 |
241 |
254 void |
242 void |
255 toggleview(Arg *arg) |
243 toggleview(Arg *arg) { |
256 { |
|
257 unsigned int i; |
244 unsigned int i; |
258 |
245 |
259 seltag[arg->i] = !seltag[arg->i]; |
246 seltag[arg->i] = !seltag[arg->i]; |
260 for(i = 0; i < ntags && !seltag[i]; i++); |
247 for(i = 0; i < ntags && !seltag[i]; i++); |
261 if(i == ntags) |
248 if(i == ntags) |
263 reorder(); |
250 reorder(); |
264 arrange(NULL); |
251 arrange(NULL); |
265 } |
252 } |
266 |
253 |
267 void |
254 void |
268 view(Arg *arg) |
255 view(Arg *arg) { |
269 { |
|
270 unsigned int i; |
256 unsigned int i; |
271 |
257 |
272 for(i = 0; i < ntags; i++) |
258 for(i = 0; i < ntags; i++) |
273 seltag[i] = False; |
259 seltag[i] = False; |
274 seltag[arg->i] = True; |
260 seltag[arg->i] = True; |
275 reorder(); |
261 reorder(); |
276 arrange(NULL); |
262 arrange(NULL); |
277 } |
263 } |
278 |
264 |
279 void |
265 void |
280 viewall(Arg *arg) |
266 viewall(Arg *arg) { |
281 { |
|
282 unsigned int i; |
267 unsigned int i; |
283 |
268 |
284 for(i = 0; i < ntags; i++) |
269 for(i = 0; i < ntags; i++) |
285 seltag[i] = True; |
270 seltag[i] = True; |
286 reorder(); |
271 reorder(); |
287 arrange(NULL); |
272 arrange(NULL); |
288 } |
273 } |
289 |
274 |
290 void |
275 void |
291 zoom(Arg *arg) |
276 zoom(Arg *arg) { |
292 { |
|
293 unsigned int n; |
277 unsigned int n; |
294 Client *c; |
278 Client *c; |
295 |
279 |
296 for(n = 0, c = clients; c; c = c->next) |
280 for(n = 0, c = clients; c; c = c->next) |
297 if(isvisible(c) && !c->isfloat) |
281 if(isvisible(c) && !c->isfloat) |