comparison client.c @ 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 056a5072c70a
children 16c4e4c5fb15
comparison
equal deleted inserted replaced
445:00584fe34361 446:a2e587651c79
7 #include <string.h> 7 #include <string.h>
8 #include <X11/Xatom.h> 8 #include <X11/Xatom.h>
9 #include <X11/Xutil.h> 9 #include <X11/Xutil.h>
10 10
11 /* static functions */ 11 /* static functions */
12
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 }
12 20
13 static void 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);
97 grabbuttons(old, False); 105 grabbuttons(old, False);
98 drawtitle(old); 106 drawtitle(old);
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);
105 } 116 }
106 else 117 else
196 } 207 }
197 208
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;
205 215
206 c = emallocz(sizeof(Client)); 216 c = emallocz(sizeof(Client));
245 c->maxw == c->minw && c->maxh == c->minh); 255 c->maxw == c->minw && c->maxh == c->minh);
246 256
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);
254 XMapWindow(dpy, c->win); 265 XMapWindow(dpy, c->win);
255 XMapWindow(dpy, c->twin); 266 XMapWindow(dpy, c->twin);
419 } 430 }
420 431
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
427 XSync(dpy, False); 439 XSync(dpy, False);
428 XSetErrorHandler(xerror); 440 XSetErrorHandler(xerror);