about summary refs log tree commit diff stats
path: root/client.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-19 13:42:39 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-19 13:42:39 +0100
commit30af19d4426ca32dc38318bbe87534cc44484998 (patch)
treec3d862223531f5b02e3cb6e31b7e9ee5d38193a6 /client.c
parent5d9146ff372ae0c5196e290fb2c1f828d4137e20 (diff)
downloaddwm-30af19d4426ca32dc38318bbe87534cc44484998.tar.gz
added some new convenience functions
Diffstat (limited to 'client.c')
-rw-r--r--client.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/client.c b/client.c
index 79cd698..9a30526 100644
--- a/client.c
+++ b/client.c
@@ -10,13 +10,6 @@
 /* static */
 
 static void
-detachstack(Client *c) {
-	Client **tc;
-	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
-	*tc = c->snext;
-}
-
-static void
 grabbuttons(Client *c, Bool focused) {
 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
 
@@ -68,6 +61,20 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
 /* extern */
 
 void
+attach(Client *c) {
+	if(clients)
+		clients->prev = c;
+	c->next = clients;
+	clients = c;
+}
+
+void
+attachstack(Client *c) {
+	c->snext = stack;
+	stack = c;
+}
+
+void
 configure(Client *c) {
 	XConfigureEvent ce;
 
@@ -86,6 +93,24 @@ configure(Client *c) {
 }
 
 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
+detachstack(Client *c) {
+	Client **tc;
+	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
+	*tc = c->snext;
+}
+
+void
 focus(Client *c) {
 	if(c && !isvisible(c))
 		return;
@@ -95,8 +120,7 @@ focus(Client *c) {
 	}
 	if(c) {
 		detachstack(c);
-		c->snext = stack;
-		stack = c;
+		attachstack(c);
 		grabbuttons(c, True);
 	}
 	sel = c;
@@ -189,11 +213,8 @@ manage(Window w, XWindowAttributes *wa) {
 	settags(c, t);
 	if(!c->isfloat)
 		c->isfloat = (t != 0) || c->isfixed;
-	if(clients)
-		clients->prev = c;
-	c->next = clients;
-	c->snext = stack;
-	stack = clients = c;
+	attach(c);
+	attachstack(c);
 	c->isbanned = True;
 	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
 	XMapWindow(dpy, c->win);
ame/go.sum?h=0.5.0&id=48758136c03b89757f7df1dd26331169c3d4ca02'>^
bbdf9df ^

6473848 ^

56b84d3 ^

974b22c ^

b0eaf51 ^
974b22c ^


d394fd1 ^

072bc26 ^

0c2ede5 ^

072bc26 ^

0c2ede5 ^

56b84d3 ^

475b697 ^

974b22c ^

0c2ede5 ^

1170893 ^

56b84d3 ^

974b22c ^

513e8aa ^

cef784b ^

8d20e92 ^

974b22c ^

072bc26 ^

974b22c ^



8d20e92 ^


2485d50 ^

072bc26 ^
974b22c ^
855362d ^
b0eaf51 ^


072bc26 ^
974b22c ^

b47143c ^

b0eaf51 ^


974b22c ^
072bc26 ^
0c2ede5 ^
974b22c ^

84f49e9 ^
b47143c ^

648ca98 ^

072bc26 ^



974b22c ^
b0eaf51 ^
974b22c ^



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