aewl
changeset 446:a2e587651c79
using a global stack for focus recovery on arrange() - seems to work great
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Thu, 07 Sep 2006 17:53:40 +0200 |
parents | 00584fe34361 |
children | 16c4e4c5fb15 |
files | client.c dwm.h main.c view.c |
diffstat | 4 files changed, 26 insertions(+), 8 deletions(-) [+] |
line diff
1.1 --- a/client.c Thu Sep 07 09:26:01 2006 +0200 1.2 +++ b/client.c Thu Sep 07 17:53:40 2006 +0200 1.3 @@ -11,6 +11,14 @@ 1.4 /* static functions */ 1.5 1.6 static void 1.7 +detachstack(Client *c) 1.8 +{ 1.9 + Client **tc; 1.10 + for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); 1.11 + *tc = c->snext; 1.12 +} 1.13 + 1.14 +static void 1.15 grabbuttons(Client *c, Bool focus) 1.16 { 1.17 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.18 @@ -99,6 +107,9 @@ 1.19 } 1.20 } 1.21 if(c) { 1.22 + detachstack(c); 1.23 + c->snext = stack; 1.24 + stack = c; 1.25 grabbuttons(c, True); 1.26 drawtitle(c); 1.27 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 1.28 @@ -198,7 +209,6 @@ 1.29 void 1.30 manage(Window w, XWindowAttributes *wa) 1.31 { 1.32 - unsigned int i; 1.33 Client *c; 1.34 Window trans; 1.35 XSetWindowAttributes twa; 1.36 @@ -247,7 +257,8 @@ 1.37 if(clients) 1.38 clients->prev = c; 1.39 c->next = clients; 1.40 - clients = c; 1.41 + c->snext = stack; 1.42 + stack = clients = c; 1.43 1.44 settitle(c); 1.45 ban(c); 1.46 @@ -421,6 +432,7 @@ 1.47 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.48 XDestroyWindow(dpy, c->twin); 1.49 1.50 + detachstack(c); 1.51 free(c->tags); 1.52 free(c); 1.53
2.1 --- a/dwm.h Thu Sep 07 09:26:01 2006 +0200 2.2 +++ b/dwm.h Thu Sep 07 17:53:40 2006 +0200 2.3 @@ -61,6 +61,7 @@ 2.4 Bool *tags; 2.5 Client *next; 2.6 Client *prev; 2.7 + Client *snext; 2.8 Window win; 2.9 Window twin; 2.10 }; 2.11 @@ -73,7 +74,7 @@ 2.12 extern void (*arrange)(Arg *); 2.13 extern Atom wmatom[WMLast], netatom[NetLast]; 2.14 extern Bool running, issel, maximized, *seltag; 2.15 -extern Client *clients, *sel; 2.16 +extern Client *clients, *sel, *stack; 2.17 extern Cursor cursor[CurLast]; 2.18 extern DC dc; 2.19 extern Display *dpy;
3.1 --- a/main.c Thu Sep 07 09:26:01 2006 +0200 3.2 +++ b/main.c Thu Sep 07 17:53:40 2006 +0200 3.3 @@ -27,6 +27,7 @@ 3.4 Bool maximized = False; 3.5 Client *clients = NULL; 3.6 Client *sel = NULL; 3.7 +Client *stack = NULL; 3.8 Cursor cursor[CurLast]; 3.9 Display *dpy; 3.10 DC dc = {0};
4.1 --- a/view.c Thu Sep 07 09:26:01 2006 +0200 4.2 +++ b/view.c Thu Sep 07 17:53:40 2006 +0200 4.3 @@ -76,8 +76,10 @@ 4.4 else 4.5 ban(c); 4.6 } 4.7 - if(!sel || !isvisible(sel)) 4.8 - focus(getnext(clients)); 4.9 + if(!sel || !isvisible(sel)) { 4.10 + for(sel = stack; sel && !isvisible(sel); sel = sel->snext); 4.11 + focus(sel); 4.12 + } 4.13 restack(); 4.14 } 4.15 4.16 @@ -138,8 +140,10 @@ 4.17 else 4.18 ban(c); 4.19 } 4.20 - if(!sel || !isvisible(sel)) 4.21 - focus(getnext(clients)); 4.22 + if(!sel || !isvisible(sel)) { 4.23 + for(sel = stack; sel && !isvisible(sel); sel = sel->snext); 4.24 + focus(sel); 4.25 + } 4.26 restack(); 4.27 } 4.28 4.29 @@ -227,7 +231,7 @@ 4.30 XRaiseWindow(dpy, sel->win); 4.31 XRaiseWindow(dpy, sel->twin); 4.32 } 4.33 - if(arrange != dofloat) 4.34 + if(arrange != dofloat) 4.35 for(c = nexttiled(clients); c; c = nexttiled(c->next)) { 4.36 XLowerWindow(dpy, c->twin); 4.37 XLowerWindow(dpy, c->win);