aewl
changeset 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 | b1159a638d0a |
children | fc279cd6c7be |
files | client.c dwm.h view.c |
diffstat | 3 files changed, 52 insertions(+), 29 deletions(-) [+] |
line diff
1.1 --- a/client.c Mon Aug 28 14:32:51 2006 +0200 1.2 +++ b/client.c Tue Aug 29 09:23:44 2006 +0200 1.3 @@ -230,13 +230,7 @@ 1.4 DefaultVisual(dpy, screen), 1.5 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 1.6 1.7 - if(clients) 1.8 - clients->prev = c; 1.9 - c->next = clients; 1.10 - clients = c; 1.11 - 1.12 grabbuttons(c, False); 1.13 - 1.14 if((tc = getclient(trans))) /* inherit tags */ 1.15 for(i = 0; i < ntags; i++) 1.16 c->tags[i] = tc->tags[i]; 1.17 @@ -246,6 +240,9 @@ 1.18 c->isfloat = trans 1.19 || (c->maxw && c->minw && 1.20 c->maxw == c->minw && c->maxh == c->minh); 1.21 + 1.22 + attach(c); 1.23 + 1.24 settitle(c); 1.25 if(isvisible(c)) 1.26 sel = c; 1.27 @@ -407,12 +404,7 @@ 1.28 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.29 XDestroyWindow(dpy, c->twin); 1.30 1.31 - if(c->prev) 1.32 - c->prev->next = c->next; 1.33 - if(c->next) 1.34 - c->next->prev = c->prev; 1.35 - if(c == clients) 1.36 - clients = c->next; 1.37 + detach(c); 1.38 if(sel == c) { 1.39 if(trans && (tc = getclient(trans)) && isvisible(tc)) 1.40 sel = tc;
2.1 --- a/dwm.h Mon Aug 28 14:32:51 2006 +0200 2.2 +++ b/dwm.h Tue Aug 29 09:23:44 2006 +0200 2.3 @@ -127,6 +127,8 @@ 2.4 extern void spawn(Arg *arg); 2.5 2.6 /* view.c */ 2.7 +extern void attach(Client *c); 2.8 +extern void detach(Client *c); 2.9 extern void dofloat(Arg *arg); 2.10 extern void dotile(Arg *arg); 2.11 extern void focusnext(Arg *arg);
3.1 --- a/view.c Mon Aug 28 14:32:51 2006 +0200 3.2 +++ b/view.c Tue Aug 29 09:23:44 2006 +0200 3.3 @@ -9,6 +9,45 @@ 3.4 void (*arrange)(Arg *) = DEFMODE; 3.5 3.6 void 3.7 +attach(Client *c) 3.8 +{ 3.9 + Client *first = getnext(clients); 3.10 + 3.11 + if(!first) { 3.12 + if(clients) { 3.13 + for(first = clients; first->next; first = first->next); 3.14 + first->next = c; 3.15 + c->prev = first; 3.16 + } 3.17 + else 3.18 + clients = c; 3.19 + } 3.20 + else if(first == clients) { 3.21 + c->next = clients; 3.22 + clients->prev = c; 3.23 + clients = c; 3.24 + } 3.25 + else { 3.26 + first->prev->next = c; 3.27 + c->prev = first->prev; 3.28 + first->prev = c; 3.29 + c->next = first; 3.30 + } 3.31 +} 3.32 + 3.33 +void 3.34 +detach(Client *c) 3.35 +{ 3.36 + if(c->prev) 3.37 + c->prev->next = c->next; 3.38 + if(c->next) 3.39 + c->next->prev = c->prev; 3.40 + if(c == clients) 3.41 + clients = c->next; 3.42 + c->next = c->prev = NULL; 3.43 +} 3.44 + 3.45 +void 3.46 dofloat(Arg *arg) 3.47 { 3.48 Client *c; 3.49 @@ -228,26 +267,16 @@ 3.50 void 3.51 zoom(Arg *arg) 3.52 { 3.53 - Client *c; 3.54 + Client *c = sel; 3.55 3.56 - if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax) 3.57 + if(!c || (arrange != dotile) || c->isfloat || c->ismax) 3.58 return; 3.59 3.60 - if(sel == getnext(clients)) { 3.61 - if((c = getnext(sel->next))) 3.62 - sel = c; 3.63 - else 3.64 + if(c == getnext(clients)) 3.65 + if(!(c = getnext(c->next))) 3.66 return; 3.67 - } 3.68 - 3.69 - /* pop */ 3.70 - sel->prev->next = sel->next; 3.71 - if(sel->next) 3.72 - sel->next->prev = sel->prev; 3.73 - sel->prev = NULL; 3.74 - clients->prev = sel; 3.75 - sel->next = clients; 3.76 - clients = sel; 3.77 - focus(sel); 3.78 + detach(c); 3.79 + attach(c); 3.80 + focus(c); 3.81 arrange(NULL); 3.82 }