about summary refs log tree commit diff stats
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
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
-rw-r--r--client.c16
-rw-r--r--dwm.h2
-rw-r--r--view.c63
3 files changed, 52 insertions, 29 deletions
diff --git a/client.c b/client.c
index 9c0428a..0a7df77 100644
--- a/client.c
+++ b/client.c
@@ -230,13 +230,7 @@ manage(Window w, XWindowAttributes *wa)
 			DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
 
-	if(clients)
-		clients->prev = c;
-	c->next = clients;
-	clients = c;
-
 	grabbuttons(c, False);
-
 	if((tc = getclient(trans))) /* inherit tags */
 		for(i = 0; i < ntags; i++)
 			c->tags[i] = tc->tags[i];
@@ -246,6 +240,9 @@ manage(Window w, XWindowAttributes *wa)
 		c->isfloat = trans
 			|| (c->maxw && c->minw &&
 				c->maxw == c->minw && c->maxh == c->minh);
+
+	attach(c);
+
 	settitle(c);
 	if(isvisible(c))
 		sel = c;
@@ -407,12 +404,7 @@ unmanage(Client *c)
 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
 	XDestroyWindow(dpy, c->twin);
 
-	if(c->prev)
-		c->prev->next = c->next;
-	if(c->next)
-		c->next->prev = c->prev;
-	if(c == clients)
-		clients = c->next;
+	detach(c);
 	if(sel == c) {
 		if(trans && (tc = getclient(trans)) && isvisible(tc))
 			sel = tc;
diff --git a/dwm.h b/dwm.h
index 4d23cab..6bb6b3a 100644
--- a/dwm.h
+++ b/dwm.h
@@ -127,6 +127,8 @@ extern void *erealloc(void *ptr, unsigned int size);
 extern void spawn(Arg *arg);
 
 /* view.c */
+extern void attach(Client *c);
+extern void detach(Client *c);
 extern void dofloat(Arg *arg);
 extern void dotile(Arg *arg);
 extern void focusnext(Arg *arg);
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);
 }
lt'>
e47cfd56 ^
af9be28b ^
e47cfd56 ^
08fc6e5c ^
169e8098 ^
d2e46bbf ^
e4409c40 ^






e4409c40 ^

55ebd12c ^















8ce6b560 ^
55ebd12c ^


d97a6513 ^
55ebd12c ^









a2e94617 ^
55ebd12c ^
8ce6b560 ^
55ebd12c ^
55ebd12c ^
8ce6b560 ^
55ebd12c ^



e4409c40 ^




8c68f693 ^

e47cfd56 ^
8c68f693 ^
e4409c40 ^
8c68f693 ^
e4409c40 ^
8c68f693 ^
d2e46bbf ^

e4409c40 ^

d2e46bbf ^
79de4059 ^
e4409c40 ^

2b52e9e6 ^
e4409c40 ^
2f5222ea ^

86b4d41a ^








d3f9d547 ^
86b4d41a ^




8ce6b560 ^
86b4d41a ^


d97a6513 ^
86b4d41a ^









a2e94617 ^
86b4d41a ^
8ce6b560 ^
86b4d41a ^
86b4d41a ^
8ce6b560 ^
86b4d41a ^



e4409c40 ^

8c68f693 ^
e4409c40 ^



1a2ac66b ^

d2e46bbf ^
1a2ac66b ^

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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168