comparison view.c @ 378:83576f5f0a90

added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
author Anselm R. Garbe <arg@10kloc.org>
date Tue, 29 Aug 2006 09:23:44 +0200
parents a1901753deef
children 4bf79305d675
comparison
equal deleted inserted replaced
377:b1159a638d0a 378:83576f5f0a90
5 #include "dwm.h" 5 #include "dwm.h"
6 6
7 /* extern */ 7 /* extern */
8 8
9 void (*arrange)(Arg *) = DEFMODE; 9 void (*arrange)(Arg *) = DEFMODE;
10
11 void
12 attach(Client *c)
13 {
14 Client *first = getnext(clients);
15
16 if(!first) {
17 if(clients) {
18 for(first = clients; first->next; first = first->next);
19 first->next = c;
20 c->prev = first;
21 }
22 else
23 clients = c;
24 }
25 else if(first == clients) {
26 c->next = clients;
27 clients->prev = c;
28 clients = c;
29 }
30 else {
31 first->prev->next = c;
32 c->prev = first->prev;
33 first->prev = c;
34 c->next = first;
35 }
36 }
37
38 void
39 detach(Client *c)
40 {
41 if(c->prev)
42 c->prev->next = c->next;
43 if(c->next)
44 c->next->prev = c->prev;
45 if(c == clients)
46 clients = c->next;
47 c->next = c->prev = NULL;
48 }
10 49
11 void 50 void
12 dofloat(Arg *arg) 51 dofloat(Arg *arg)
13 { 52 {
14 Client *c; 53 Client *c;
226 } 265 }
227 266
228 void 267 void
229 zoom(Arg *arg) 268 zoom(Arg *arg)
230 { 269 {
231 Client *c; 270 Client *c = sel;
232 271
233 if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax) 272 if(!c || (arrange != dotile) || c->isfloat || c->ismax)
234 return; 273 return;
235 274
236 if(sel == getnext(clients)) { 275 if(c == getnext(clients))
237 if((c = getnext(sel->next))) 276 if(!(c = getnext(c->next)))
238 sel = c;
239 else
240 return; 277 return;
241 } 278 detach(c);
242 279 attach(c);
243 /* pop */ 280 focus(c);
244 sel->prev->next = sel->next;
245 if(sel->next)
246 sel->next->prev = sel->prev;
247 sel->prev = NULL;
248 clients->prev = sel;
249 sel->next = clients;
250 clients = sel;
251 focus(sel);
252 arrange(NULL); 281 arrange(NULL);
253 } 282 }