sanders solution is convincing and elegant
authorAnselm R. Garbe <arg@10kloc.org>
Wed, 06 Sep 2006 11:54:16 +0200
changeset 436 b3659c3c5dab
parent 435 42388f634de0
child 437 433a5c662f73
sanders solution is convincing and elegant
client.c
view.c
--- a/client.c	Wed Sep 06 11:46:35 2006 +0200
+++ b/client.c	Wed Sep 06 11:54:16 2006 +0200
@@ -99,14 +99,6 @@
 		}
 	}
 	if(c) {
-		if((c->isfloat || arrange == dofloat) && (c != clients)) {
-			detach(c);
-			if(clients) {
-				clients->prev = c;
-				c->next = clients;
-			}
-			clients = c;
-		}
 		grabbuttons(c, True);
 		drawtitle(c);
 		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
--- a/view.c	Wed Sep 06 11:46:35 2006 +0200
+++ b/view.c	Wed Sep 06 11:54:16 2006 +0200
@@ -215,52 +215,20 @@
 void
 restack()
 {
-	static unsigned int nwins = 0;
-	static Window *wins = NULL;
-	unsigned int f, fi, m, mi, n;
 	Client *c;
 	XEvent ev;
-
-	for(f = 0, m = 0, c = clients; c; c = c->next)
-		if(isvisible(c)) {
-			if(c->isfloat || arrange == dofloat)
-				f++;
-			else
-				m++;
-		}
-	if(!(n = 2 * (f + m))) {
-		drawstatus();
+	
+	if(!sel)
 		return;
-	}
-	if(nwins < n) {
-		nwins = n;
-		wins = erealloc(wins, nwins * sizeof(Window));
+	if(sel->isfloat || arrange == dofloat) {
+		XRaiseWindow(dpy, sel->win);
+		XRaiseWindow(dpy, sel->twin);
 	}
-
-	fi = 0;
-	mi = 2 * f;
-	if(sel) {
-		if(sel->isfloat || arrange == dofloat) {
-			wins[fi++] = sel->twin;
-			wins[fi++] = sel->win;
-		}
-		else {
-			wins[mi++] = sel->twin;
-			wins[mi++] = sel->win;
+	if(arrange != dofloat) 
+		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
+			XLowerWindow(dpy, c->twin);
+			XLowerWindow(dpy, c->win);
 		}
-	}
-	for(c = clients; c; c = c->next)
-		if(isvisible(c) && c != sel) {
-			if(c->isfloat || arrange == dofloat) {
-				wins[fi++] = c->twin;
-				wins[fi++] = c->win;
-			}
-			else {
-				wins[mi++] = c->twin;
-				wins[mi++] = c->win;
-			}
-		}
-	XRestackWindows(dpy, wins, n);
 	drawall();
 	XSync(dpy, False);
 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));