dwm-meillo

diff 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
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