about summary refs log tree commit diff stats
path: root/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'view.c')
-rw-r--r--view.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/view.c b/view.c
index 9ba8e0b..ac336e3 100644
--- a/view.c
+++ b/view.c
@@ -4,6 +4,31 @@
  */
 #include "dwm.h"
 
+/* static */
+
+static Client *
+getslot(Client *c)
+{
+	unsigned int i, tic;
+	Client *p;
+
+	for(tic = 0; tic < ntags && !c->tags[tic]; tic++);
+	for(p = clients; p; p = p->next) {
+		for(i = 0; i < ntags && !p->tags[i]; i++);
+		if(tic < i)
+			return p;
+	}
+	return p;
+}
+
+static Client *
+tail()
+{
+	Client *c;
+	for(c = clients; c && c->next; c = c->next);
+	return c;
+}
+
 /* extern */
 
 void (*arrange)(Arg *) = DEFMODE;
@@ -11,27 +36,29 @@ void (*arrange)(Arg *) = DEFMODE;
 void
 attach(Client *c)
 {
-	Client *first = getnext(clients);
+	Client *p;
 
-	if(!first) {
-		if(clients) {
-			for(first = clients; first->next; first = first->next);
-			first->next = c;
-			c->prev = first;
-		}
-		else
-			clients = c;
+	if(!clients) {
+		clients = c;
+		return;
+	}
+	if(!(p = getnext(clients)) && !(p = getslot(c))) {
+		p = tail();
+		c->prev = p;
+		p->next = c;
+		return;
 	}
-	else if(first == clients) {
+
+	if(p == clients) {
 		c->next = clients;
 		clients->prev = c;
 		clients = c;
 	}
 	else {
-		first->prev->next = c;
-		c->prev = first->prev;
-		first->prev = c;
-		c->next = first;
+		p->prev->next = c;
+		c->prev = p->prev;
+		p->prev = c;
+		c->next = p;
 	}
 }
 
.org> 2006-08-08 09:30:45 +0200 committer Anselm R.Garbe <arg@10ksloc.org> 2006-08-08 09:30:45 +0200 applied Sanders tiny patches' href='/acidbong/suckless/dwm/commit/Makefile?h=2.5&id=42277b111018c5e83cc867b04156511aa0914bf1'>42277b1 ^
5d3fd37 ^
a2d56f6 ^
99b126d ^

1076f2b
650a1fb ^
1076f2b
95766d6 ^
82064af ^
1076f2b

4d55eee ^
db876f9 ^
dbf7e03 ^

4d55eee ^






dbf7e03 ^

4d55eee ^
dbf7e03 ^
4d55eee ^


dbf7e03 ^
d9386a0 ^
4d55eee ^
dbf7e03 ^

4d55eee ^



dc5c070 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62