diff options
| -rw-r--r-- | client.c | 16 | ||||
| -rw-r--r-- | dwm.h | 3 | ||||
| -rw-r--r-- | main.c | 1 | ||||
| -rw-r--r-- | view.c | 14 |
4 files changed, 26 insertions, 8 deletions
| @@ -11,6 +11,14 @@ | |||
| 11 | /* static functions */ | 11 | /* static functions */ |
| 12 | 12 | ||
| 13 | static void | 13 | static void |
| 14 | detachstack(Client *c) | ||
| 15 | { | ||
| 16 | Client **tc; | ||
| 17 | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); | ||
| 18 | *tc = c->snext; | ||
| 19 | } | ||
| 20 | |||
| 21 | static void | ||
| 14 | grabbuttons(Client *c, Bool focus) | 22 | grabbuttons(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) | |||
| 198 | void | 209 | void |
| 199 | manage(Window w, XWindowAttributes *wa) | 210 | manage(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 | ||
| @@ -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 *); | |||
| 73 | extern void (*arrange)(Arg *); | 74 | extern void (*arrange)(Arg *); |
| 74 | extern Atom wmatom[WMLast], netatom[NetLast]; | 75 | extern Atom wmatom[WMLast], netatom[NetLast]; |
| 75 | extern Bool running, issel, maximized, *seltag; | 76 | extern Bool running, issel, maximized, *seltag; |
| 76 | extern Client *clients, *sel; | 77 | extern Client *clients, *sel, *stack; |
| 77 | extern Cursor cursor[CurLast]; | 78 | extern Cursor cursor[CurLast]; |
| 78 | extern DC dc; | 79 | extern DC dc; |
| 79 | extern Display *dpy; | 80 | extern Display *dpy; |
| @@ -27,6 +27,7 @@ Bool issel = True; | |||
| 27 | Bool maximized = False; | 27 | Bool maximized = False; |
| 28 | Client *clients = NULL; | 28 | Client *clients = NULL; |
| 29 | Client *sel = NULL; | 29 | Client *sel = NULL; |
| 30 | Client *stack = NULL; | ||
| 30 | Cursor cursor[CurLast]; | 31 | Cursor cursor[CurLast]; |
| 31 | Display *dpy; | 32 | Display *dpy; |
| 32 | DC dc = {0}; | 33 | DC dc = {0}; |
| @@ -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); |
