layout.c
changeset 904 2dfd50e4cfde
parent 901 8f6f61e07567
child 905 ca352bd2f8f7
--- a/layout.c	Mon May 28 15:05:47 2007 +0200
+++ b/layout.c	Tue May 29 11:35:20 2007 +0200
@@ -14,6 +14,22 @@
 static unsigned int nmaster = NMASTER;
 
 static void
+ban(Client *c) {
+	if (c->isbanned)
+		return;
+	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+	c->isbanned = True;
+}
+
+static void
+unban(Client *c) {
+	if (!c->isbanned)
+		return;
+	XMoveWindow(dpy, c->win, c->x, c->y);
+	c->isbanned = False;
+}
+
+static void
 tile(void) {
 	unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
 	Client *c;
@@ -28,9 +44,7 @@
 
 	for(i = 0, c = clients; c; c = c->next)
 		if(isvisible(c)) {
-			if(c->isbanned)
-				XMoveWindow(dpy, c->win, c->x, c->y);
-			c->isbanned = False;
+			unban(c);
 			if(c->isfloating)
 				continue;
 			c->ismax = False;
@@ -60,12 +74,9 @@
 			resize(c, nx, ny, nw, nh, False);
 			i++;
 		}
-		else {
-			c->isbanned = True;
-			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
-		}
-	if(!sel || !isvisible(sel)) 
-		focustopvisible();
+		else
+			ban(c);
+	focus(NULL);
 	restack();
 }
 
@@ -77,20 +88,16 @@
 floating(void) {
 	Client *c;
 
-	for(c = clients; c; c = c->next) {
+	for(c = clients; c; c = c->next)
 		if(isvisible(c)) {
 			if(c->isbanned)
 				XMoveWindow(dpy, c->win, c->x, c->y);
 			c->isbanned = False;
 			resize(c, c->x, c->y, c->w, c->h, True);
 		}
-		else {
-			c->isbanned = True;
-			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
-		}
-	}
-	if(!sel || !isvisible(sel))
-		focustopvisible();
+		else
+			ban(c);
+	focus(NULL);
 	restack();
 }