about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-12 17:17:15 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-12 17:17:15 +0200
commit2e836ecce1ba0629a6088b739c1092d27fccd72b (patch)
tree3761067105ab4cd3d2d2843fda154090a20c98be
parent6db5ffb6c9a9c0db5c425c64a96a3896a682c95e (diff)
downloaddwm-2e836ecce1ba0629a6088b739c1092d27fccd72b.tar.gz
added gravity stuff
-rw-r--r--client.c72
-rw-r--r--event.c4
-rw-r--r--kb.c2
-rw-r--r--wm.h5
4 files changed, 76 insertions, 7 deletions
diff --git a/client.c b/client.c
index 537336c..e9b83fe 100644
--- a/client.c
+++ b/client.c
@@ -18,9 +18,10 @@ max(void *aux)
 		return;
 	stack->x = sx;
 	stack->y = bh;
-	stack->w = sw - 2;
-	stack->h = sh - bh - 2;
+	stack->w = sw - 2 * stack->border;
+	stack->h = sh - bh - 2 * stack->border;
 	resize(stack);
+	discard_events(EnterWindowMask);
 }
 
 void
@@ -43,8 +44,8 @@ arrange(void *aux)
 	else
 		cols = rows;
 
-	gw = (sw - 1)  / cols;
-	gh = (sh - bh - 1) / rows;
+	gw = (sw - 2 * c->border)  / cols;
+	gh = (sh - bh - 2 * c->border) / rows;
 
 	for(i = j = 0, c = clients; c; c = c->next) {
 		c->x = i * gw;
@@ -57,6 +58,7 @@ arrange(void *aux)
 			i = 0;
 		}
 	}
+	discard_events(EnterWindowMask);
 }
 
 void
@@ -161,6 +163,10 @@ update_size(Client *c)
 	}
 	else
 		c->minw = c->minh = 0;
+	if(c->flags & PWinGravity)
+		c->grav = size.win_gravity;
+	else
+		c->grav = NorthWestGravity;
 }
 
 void
@@ -213,6 +219,7 @@ manage(Window w, XWindowAttributes *wa)
 	c->tw = c->w = wa->width;
 	c->h = wa->height;
 	c->th = bh;
+	c->border = 1;
 	update_size(c);
 	XSetWindowBorderWidth(dpy, c->win, 1);
 	XSetWindowBorder(dpy, c->win, brush.border);
@@ -247,6 +254,61 @@ manage(Window w, XWindowAttributes *wa)
 }
 
 void
+gravitate(Client *c, Bool invert)
+{
+	int dx = 0, dy = 0;
+
+	switch(c->grav) {
+	case StaticGravity:
+	case NorthWestGravity:
+	case NorthGravity:
+	case NorthEastGravity:
+		dy = c->border;
+		break;
+	case EastGravity:
+	case CenterGravity:
+	case WestGravity:
+		dy = -(c->h / 2) + c->border;
+		break;
+	case SouthEastGravity:
+	case SouthGravity:
+	case SouthWestGravity:
+		dy = -c->h;
+		break;
+	default:
+		break;
+	}
+
+	switch (c->grav) {
+	case StaticGravity:
+	case NorthWestGravity:
+	case WestGravity:
+	case SouthWestGravity:
+		dx = c->border;
+		break;
+	case NorthGravity:
+	case CenterGravity:
+	case SouthGravity:
+		dx = -(c->w / 2) + c->border;
+		break;
+	case NorthEastGravity:
+	case EastGravity:
+	case SouthEastGravity:
+		dx = -(c->w + c->border);
+		break;
+	default:
+		break;
+	}
+
+	if(invert) {
+		dx = -dx;
+		dy = -dy;
+	}
+	c->x += dx;
+	c->y += dy;
+}
+
+void
 resize(Client *c)
 {
 	XConfigureEvent e;
@@ -260,7 +322,7 @@ resize(Client *c)
 	e.y = c->y;
 	e.width = c->w;
 	e.height = c->h;
-	e.border_width = 0;
+	e.border_width = c->border;
 	e.above = None;
 	e.override_redirect = False;
 	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
diff --git a/event.c b/event.c
index 1db3d96..93007df 100644
--- a/event.c
+++ b/event.c
@@ -77,6 +77,7 @@ configurerequest(XEvent *e)
 
 	ev->value_mask &= ~CWSibling;
 	if((c = getclient(ev->window))) {
+		gravitate(c, True);
 		if(ev->value_mask & CWX)
 			c->x = ev->x;
 		if(ev->value_mask & CWY)
@@ -85,6 +86,9 @@ configurerequest(XEvent *e)
 			c->w = ev->width;
 		if(ev->value_mask & CWHeight)
 			c->h = ev->height;
+		if(ev->value_mask & CWBorderWidth)
+			c->border = ev->border_width;
+		gravitate(c, False);
 	}
 
 	wc.x = ev->x;
diff --git a/kb.c b/kb.c
index 76c8be1..ad7c717 100644
--- a/kb.c
+++ b/kb.c
@@ -8,7 +8,7 @@
 #include <X11/keysym.h>
 
 static const char *term[] = { 
-	"xterm", "-bg", "black", "-fg", "white", "-fn",
+	"aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
 	"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", 0 
 };
 
diff --git a/wm.h b/wm.h
index 3d9b63c..ee89f5b 100644
--- a/wm.h
+++ b/wm.h
@@ -27,6 +27,8 @@ struct Client {
 	int x, y, w, h;
 	int tx, ty, tw, th;
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+	int grav;
+	unsigned int border;
 	long flags; 
 	Window win;
 	Window trans;
@@ -73,7 +75,8 @@ extern void lower(Client *c);
 extern void kill(void *aux);
 extern void sel(void *aux);
 extern void max(void *aux);
-extern void arrange();
+extern void arrange(void *aux);
+extern void gravitate(Client *c, Bool invert);
 
 /* event.c */
 extern void discard_events(long even_mask);
d'>53f9d91d ^
445c7341 ^
53f9d91d ^
445c7341 ^
53f9d91d ^
11f7aa67 ^
445c7341 ^



53f9d91d ^
53f9d91d ^
445c7341 ^
53f9d91d ^
445c7341 ^


53f9d91d ^
445c7341 ^
53f9d91d ^



445c7341 ^
53f9d91d ^
445c7341 ^
53f9d91d ^

445c7341 ^
53f9d91d ^
445c7341 ^
53f9d91d ^
445c7341 ^
53f9d91d ^
445c7341 ^
53f9d91d ^




445c7341 ^



53f9d91d ^
445c7341 ^


53f9d91d ^



445c7341 ^
53f9d91d ^
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187