summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@10kloc.org>2006-09-07 17:53:40 +0200
committerAnselm R. Garbe <arg@10kloc.org>2006-09-07 17:53:40 +0200
commit15abade2720158fd35dcf59aa2cd5cbb325a849c (patch)
treef6255eca60e10fe5c305054e6adac07274c5a513
parentmade markups in dwm.1 more consistent (diff)
downloaddwm-15abade2720158fd35dcf59aa2cd5cbb325a849c.tar.gz
dwm-15abade2720158fd35dcf59aa2cd5cbb325a849c.zip
using a global stack for focus recovery on arrange() - seems to work great
Diffstat (limited to '')
-rw-r--r--client.c16
-rw-r--r--dwm.h3
-rw-r--r--main.c1
-rw-r--r--view.c14
4 files changed, 26 insertions, 8 deletions
diff --git a/client.c b/client.c
index 586a87f..3578beb 100644
--- a/client.c
+++ b/client.c
@@ -11,6 +11,14 @@
11/* static functions */ 11/* static functions */
12 12
13static void 13static void
14detachstack(Client *c)
15{
16 Client **tc;
17 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
18 *tc = c->snext;
19}
20
21static void
14grabbuttons(Client *c, Bool focus) 22grabbuttons(Client *c, Bool focus)
15{ 23{
16 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 24 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
@@ -99,6 +107,9 @@ focus(Client *c)
99 } 107 }
100 } 108 }
101 if(c) { 109 if(c) {
110 detachstack(c);
111 c->snext = stack;
112 stack = c;
102 grabbuttons(c, True); 113 grabbuttons(c, True);
103 drawtitle(c); 114 drawtitle(c);
104 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 115 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
@@ -198,7 +209,6 @@ killclient(Arg *arg)
198void 209void
199manage(Window w, XWindowAttributes *wa) 210manage(Window w, XWindowAttributes *wa)
200{ 211{
201 unsigned int i;
202 Client *c; 212 Client *c;
203 Window trans; 213 Window trans;
204 XSetWindowAttributes twa; 214 XSetWindowAttributes twa;
@@ -247,7 +257,8 @@ manage(Window w, XWindowAttributes *wa)
247 if(clients) 257 if(clients)
248 clients->prev = c; 258 clients->prev = c;
249 c->next = clients; 259 c->next = clients;
250 clients = c; 260 c->snext = stack;
261 stack = clients = c;
251 262
252 settitle(c); 263 settitle(c);
253 ban(c); 264 ban(c);
@@ -421,6 +432,7 @@ unmanage(Client *c)
421 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 432 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
422 XDestroyWindow(dpy, c->twin); 433 XDestroyWindow(dpy, c->twin);
423 434
435 detachstack(c);
424 free(c->tags); 436 free(c->tags);
425 free(c); 437 free(c);
426 438
diff --git a/dwm.h b/dwm.h
index eba3a6a..dd536b8 100644
--- a/dwm.h
+++ b/dwm.h
@@ -61,6 +61,7 @@ struct Client {
61 Bool *tags; 61 Bool *tags;
62 Client *next; 62 Client *next;
63 Client *prev; 63 Client *prev;
64 Client *snext;
64 Window win; 65 Window win;
65 Window twin; 66 Window twin;
66}; 67};
@@ -73,7 +74,7 @@ extern void (*handler[LASTEvent])(XEvent *);
73extern void (*arrange)(Arg *); 74extern void (*arrange)(Arg *);
74extern Atom wmatom[WMLast], netatom[NetLast]; 75extern Atom wmatom[WMLast], netatom[NetLast];
75extern Bool running, issel, maximized, *seltag; 76extern Bool running, issel, maximized, *seltag;
76extern Client *clients, *sel; 77extern Client *clients, *sel, *stack;
77extern Cursor cursor[CurLast]; 78extern Cursor cursor[CurLast];
78extern DC dc; 79extern DC dc;
79extern Display *dpy; 80extern Display *dpy;
diff --git a/main.c b/main.c
index daeaa0a..5e7b4a6 100644
--- a/main.c
+++ b/main.c
@@ -27,6 +27,7 @@ Bool issel = True;
27Bool maximized = False; 27Bool maximized = False;
28Client *clients = NULL; 28Client *clients = NULL;
29Client *sel = NULL; 29Client *sel = NULL;
30Client *stack = NULL;
30Cursor cursor[CurLast]; 31Cursor cursor[CurLast];
31Display *dpy; 32Display *dpy;
32DC dc = {0}; 33DC dc = {0};
diff --git a/view.c b/view.c
index 9ee4c78..5cbab08 100644
--- a/view.c
+++ b/view.c
@@ -76,8 +76,10 @@ dofloat(Arg *arg)
76 else 76 else
77 ban(c); 77 ban(c);
78 } 78 }
79 if(!sel || !isvisible(sel)) 79 if(!sel || !isvisible(sel)) {
80 focus(getnext(clients)); 80 for(sel = stack; sel && !isvisible(sel); sel = sel->snext);
81 focus(sel);
82 }
81 restack(); 83 restack();
82} 84}
83 85
@@ -138,8 +140,10 @@ dotile(Arg *arg)
138 else 140 else
139 ban(c); 141 ban(c);
140 } 142 }
141 if(!sel || !isvisible(sel)) 143 if(!sel || !isvisible(sel)) {
142 focus(getnext(clients)); 144 for(sel = stack; sel && !isvisible(sel); sel = sel->snext);
145 focus(sel);
146 }
143 restack(); 147 restack();
144} 148}
145 149
@@ -227,7 +231,7 @@ restack()
227 XRaiseWindow(dpy, sel->win); 231 XRaiseWindow(dpy, sel->win);
228 XRaiseWindow(dpy, sel->twin); 232 XRaiseWindow(dpy, sel->twin);
229 } 233 }
230 if(arrange != dofloat) 234 if(arrange != dofloat)
231 for(c = nexttiled(clients); c; c = nexttiled(c->next)) { 235 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
232 XLowerWindow(dpy, c->twin); 236 XLowerWindow(dpy, c->twin);
233 XLowerWindow(dpy, c->win); 237 XLowerWindow(dpy, c->win);