aewl

diff view.c @ 436:b3659c3c5dab

sanders solution is convincing and elegant
author Anselm R. Garbe <arg@10kloc.org>
date Wed, 06 Sep 2006 11:54:16 +0200
parents a6b8994af164
children 433a5c662f73
line diff
     1.1 --- a/view.c	Wed Sep 06 11:46:35 2006 +0200
     1.2 +++ b/view.c	Wed Sep 06 11:54:16 2006 +0200
     1.3 @@ -215,52 +215,20 @@
     1.4  void
     1.5  restack()
     1.6  {
     1.7 -	static unsigned int nwins = 0;
     1.8 -	static Window *wins = NULL;
     1.9 -	unsigned int f, fi, m, mi, n;
    1.10  	Client *c;
    1.11  	XEvent ev;
    1.12 -
    1.13 -	for(f = 0, m = 0, c = clients; c; c = c->next)
    1.14 -		if(isvisible(c)) {
    1.15 -			if(c->isfloat || arrange == dofloat)
    1.16 -				f++;
    1.17 -			else
    1.18 -				m++;
    1.19 +	
    1.20 +	if(!sel)
    1.21 +		return;
    1.22 +	if(sel->isfloat || arrange == dofloat) {
    1.23 +		XRaiseWindow(dpy, sel->win);
    1.24 +		XRaiseWindow(dpy, sel->twin);
    1.25 +	}
    1.26 +	if(arrange != dofloat) 
    1.27 +		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
    1.28 +			XLowerWindow(dpy, c->twin);
    1.29 +			XLowerWindow(dpy, c->win);
    1.30  		}
    1.31 -	if(!(n = 2 * (f + m))) {
    1.32 -		drawstatus();
    1.33 -		return;
    1.34 -	}
    1.35 -	if(nwins < n) {
    1.36 -		nwins = n;
    1.37 -		wins = erealloc(wins, nwins * sizeof(Window));
    1.38 -	}
    1.39 -
    1.40 -	fi = 0;
    1.41 -	mi = 2 * f;
    1.42 -	if(sel) {
    1.43 -		if(sel->isfloat || arrange == dofloat) {
    1.44 -			wins[fi++] = sel->twin;
    1.45 -			wins[fi++] = sel->win;
    1.46 -		}
    1.47 -		else {
    1.48 -			wins[mi++] = sel->twin;
    1.49 -			wins[mi++] = sel->win;
    1.50 -		}
    1.51 -	}
    1.52 -	for(c = clients; c; c = c->next)
    1.53 -		if(isvisible(c) && c != sel) {
    1.54 -			if(c->isfloat || arrange == dofloat) {
    1.55 -				wins[fi++] = c->twin;
    1.56 -				wins[fi++] = c->win;
    1.57 -			}
    1.58 -			else {
    1.59 -				wins[mi++] = c->twin;
    1.60 -				wins[mi++] = c->win;
    1.61 -			}
    1.62 -		}
    1.63 -	XRestackWindows(dpy, wins, n);
    1.64  	drawall();
    1.65  	XSync(dpy, False);
    1.66  	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));