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
8a6679b3
3 file(s) · +52 −29
| 230 | 230 | DefaultVisual(dpy, screen), |
|
| 231 | 231 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); |
|
| 232 | 232 | ||
| 233 | - | if(clients) |
|
| 234 | - | clients->prev = c; |
|
| 235 | - | c->next = clients; |
|
| 236 | - | clients = c; |
|
| 237 | - | ||
| 238 | 233 | grabbuttons(c, False); |
|
| 239 | - | ||
| 240 | 234 | if((tc = getclient(trans))) /* inherit tags */ |
|
| 241 | 235 | for(i = 0; i < ntags; i++) |
|
| 242 | 236 | c->tags[i] = tc->tags[i]; |
|
| 246 | 240 | c->isfloat = trans |
|
| 247 | 241 | || (c->maxw && c->minw && |
|
| 248 | 242 | c->maxw == c->minw && c->maxh == c->minh); |
|
| 243 | + | ||
| 244 | + | attach(c); |
|
| 245 | + | ||
| 249 | 246 | settitle(c); |
|
| 250 | 247 | if(isvisible(c)) |
|
| 251 | 248 | sel = c; |
|
| 407 | 404 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 408 | 405 | XDestroyWindow(dpy, c->twin); |
|
| 409 | 406 | ||
| 410 | - | if(c->prev) |
|
| 411 | - | c->prev->next = c->next; |
|
| 412 | - | if(c->next) |
|
| 413 | - | c->next->prev = c->prev; |
|
| 414 | - | if(c == clients) |
|
| 415 | - | clients = c->next; |
|
| 407 | + | detach(c); |
|
| 416 | 408 | if(sel == c) { |
|
| 417 | 409 | if(trans && (tc = getclient(trans)) && isvisible(tc)) |
|
| 418 | 410 | sel = tc; |
|
| 127 | 127 | extern void spawn(Arg *arg); |
|
| 128 | 128 | ||
| 129 | 129 | /* view.c */ |
|
| 130 | + | extern void attach(Client *c); |
|
| 131 | + | extern void detach(Client *c); |
|
| 130 | 132 | extern void dofloat(Arg *arg); |
|
| 131 | 133 | extern void dotile(Arg *arg); |
|
| 132 | 134 | extern void focusnext(Arg *arg); |
| 9 | 9 | void (*arrange)(Arg *) = DEFMODE; |
|
| 10 | 10 | ||
| 11 | 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 | + | } |
|
| 49 | + | ||
| 50 | + | void |
|
| 12 | 51 | dofloat(Arg *arg) |
|
| 13 | 52 | { |
|
| 14 | 53 | Client *c; |
|
| 228 | 267 | void |
|
| 229 | 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 | 273 | return; |
|
| 235 | 274 | ||
| 236 | - | if(sel == getnext(clients)) { |
|
| 237 | - | if((c = getnext(sel->next))) |
|
| 238 | - | sel = c; |
|
| 239 | - | else |
|
| 275 | + | if(c == getnext(clients)) |
|
| 276 | + | if(!(c = getnext(c->next))) |
|
| 240 | 277 | return; |
|
| 241 | - | } |
|
| 242 | - | ||
| 243 | - | /* pop */ |
|
| 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); |
|
| 278 | + | detach(c); |
|
| 279 | + | attach(c); |
|
| 280 | + | focus(c); |
|
| 252 | 281 | arrange(NULL); |
|
| 253 | 282 | } |
|