about summary refs log tree commit diff stats
path: root/view.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@10kloc.org>2006-08-29 09:23:44 +0200
committerAnselm R. Garbe <arg@10kloc.org>2006-08-29 09:23:44 +0200
commit8a6679b3b4999559059df3ae9e08951099511036 (patch)
tree7b8c4ac2e4647caffba13638cac03c183c7faab2 /view.c
parent7b6d5ff29863e4bc7ba787357133ffb9bc5157e6 (diff)
downloaddwm-8a6679b3b4999559059df3ae9e08951099511036.tar.gz
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Diffstat (limited to 'view.c')
-rw-r--r--view.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/view.c b/view.c
index 0108a23..9ba8e0b 100644
--- a/view.c
+++ b/view.c
@@ -9,6 +9,45 @@
 void (*arrange)(Arg *) = DEFMODE;
 
 void
+attach(Client *c)
+{
+	Client *first = getnext(clients);
+
+	if(!first) {
+		if(clients) {
+			for(first = clients; first->next; first = first->next);
+			first->next = c;
+			c->prev = first;
+		}
+		else
+			clients = c;
+	}
+	else if(first == clients) {
+		c->next = clients;
+		clients->prev = c;
+		clients = c;
+	}
+	else {
+		first->prev->next = c;
+		c->prev = first->prev;
+		first->prev = c;
+		c->next = first;
+	}
+}
+
+void
+detach(Client *c)
+{
+	if(c->prev)
+		c->prev->next = c->next;
+	if(c->next)
+		c->next->prev = c->prev;
+	if(c == clients)
+		clients = c->next;
+	c->next = c->prev = NULL;
+}
+
+void
 dofloat(Arg *arg)
 {
 	Client *c;
@@ -228,26 +267,16 @@ view(Arg *arg)
 void
 zoom(Arg *arg)
 {
-	Client *c;
+	Client *c = sel;
 
-	if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax)
+	if(!c || (arrange != dotile) || c->isfloat || c->ismax)
 		return;
 
-	if(sel == getnext(clients))  {
-		if((c = getnext(sel->next)))
-			sel = c;
-		else
+	if(c == getnext(clients))
+		if(!(c = getnext(c->next)))
 			return;
-	}
-
-	/* pop */
-	sel->prev->next = sel->next;
-	if(sel->next)
-		sel->next->prev = sel->prev;
-	sel->prev = NULL;
-	clients->prev = sel;
-	sel->next = clients;
-	clients = sel;
-	focus(sel);
+	detach(c);
+	attach(c);
+	focus(c);
 	arrange(NULL);
 }