about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorarg@10ksloc.org <unknown>2006-07-19 11:31:04 +0200
committerarg@10ksloc.org <unknown>2006-07-19 11:31:04 +0200
commitc53980cddcee8afd13ea793134ed3ddf5dbef0e3 (patch)
tree44d98af7d722ffabac12eb271b81a74f9bd49834
parent95e56ffc0d91f55dcb138b25b6788378971485a5 (diff)
downloaddwm-c53980cddcee8afd13ea793134ed3ddf5dbef0e3.tar.gz
applied Sanders resize patch, fixed lower bug
-rw-r--r--client.c10
-rw-r--r--dwm.h5
-rw-r--r--event.c39
-rw-r--r--main.c2
-rw-r--r--tag.c6
5 files changed, 43 insertions, 19 deletions
diff --git a/client.c b/client.c
index beb7e35..af2c249 100644
--- a/client.c
+++ b/client.c
@@ -267,7 +267,7 @@ maximize(Arg *arg)
 	*sel->w = sw - 2 * sel->border;
 	*sel->h = sh - 2 * sel->border - bh;
 	higher(sel);
-	resize(sel, False);
+	resize(sel, False, TopLeft);
 }
 
 void
@@ -283,9 +283,11 @@ pop(Client *c)
 }
 
 void
-resize(Client *c, Bool inc)
+resize(Client *c, Bool inc, Corner sticky)
 {
 	XConfigureEvent e;
+	int right = *c->x + *c->w;
+	int bottom = *c->y + *c->h;
 
 	if(inc) {
 		if(c->incw)
@@ -305,6 +307,10 @@ resize(Client *c, Bool inc)
 		*c->w = c->maxw;
 	if(c->maxh && *c->h > c->maxh)
 		*c->h = c->maxh;
+	if(sticky == TopRight || sticky == BottomRight)
+		*c->x = right - *c->w;
+	if(sticky == BottomLeft || sticky == BottomRight)
+		*c->y = bottom - *c->h;
 	resizetitle(c);
 	XSetWindowBorderWidth(dpy, c->win, 1);
 	XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h);
diff --git a/dwm.h b/dwm.h
index 6b907a9..d3138be 100644
--- a/dwm.h
+++ b/dwm.h
@@ -25,6 +25,7 @@ enum { Tscratch, Tdev, Twww, Twork, TLast };
 /********** CUSTOMIZE **********/
 
 typedef union Arg Arg;
+typedef enum Corner Corner;
 typedef struct DC DC;
 typedef struct Client Client;
 typedef struct Fnt Fnt;
@@ -43,6 +44,8 @@ enum { WMProtocols, WMDelete, WMLast };
 /* cursor */
 enum { CurNormal, CurResize, CurMove, CurLast };
 
+enum Corner { TopLeft, TopRight, BottomLeft, BottomRight };
+
 struct Fnt {
 	int ascent;
 	int descent;
@@ -121,7 +124,7 @@ extern void lower(Client *c);
 extern void manage(Window w, XWindowAttributes *wa);
 extern void maximize(Arg *arg);
 extern void pop(Client *c);
-extern void resize(Client *c, Bool inc);
+extern void resize(Client *c, Bool inc, Corner sticky);
 extern void setgeom(Client *c);
 extern void setsize(Client *c);
 extern void settitle(Client *c);
diff --git a/event.c b/event.c
index db95dfd..9d69373 100644
--- a/event.c
+++ b/event.c
@@ -79,7 +79,7 @@ movemouse(Client *c)
 			XSync(dpy, False);
 			*c->x = ocx + (ev.xmotion.x - x1);
 			*c->y = ocy + (ev.xmotion.y - y1);
-			resize(c, False);
+			resize(c, False, TopLeft);
 			break;
 		case ButtonRelease:
 			XUngrabPointer(dpy, CurrentTime);
@@ -93,6 +93,7 @@ resizemouse(Client *c)
 {
 	XEvent ev;
 	int ocx, ocy;
+	Corner sticky;
 
 	ocx = *c->x;
 	ocy = *c->y;
@@ -113,7 +114,18 @@ resizemouse(Client *c)
 			*c->h = abs(ocy - ev.xmotion.y);
 			*c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w;
 			*c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - *c->h;
-			resize(c, True);
+			if(ocx <= ev.xmotion.x) {
+				if(ocy <= ev.xmotion.y)
+					sticky = TopLeft;
+				else
+					sticky = BottomLeft;
+			} else {
+				if(ocy <= ev.xmotion.y)
+					sticky = TopRight;
+				else
+					sticky = BottomRight;
+			}
+			resize(c, True, sticky);
 			break;
 		case ButtonRelease:
 			XUngrabPointer(dpy, CurrentTime);
@@ -153,24 +165,27 @@ buttonpress(XEvent *e)
 		}
 	}
 	else if((c = getclient(ev->window))) {
-		if(arrange == dotile && !c->isfloat) {
-			if((ev->state & ControlMask) && (ev->button == Button1))
-				zoom(NULL);
-			return;
-		}
-		/* floating windows */
-		higher(c);
 		switch(ev->button) {
 		default:
 			break;
 		case Button1:
-			movemouse(c);
+			if(arrange == dotile && !c->isfloat) {
+				if((ev->state & ControlMask) && (ev->button == Button1))
+					zoom(NULL);
+			}
+			else {
+				higher(c);
+				movemouse(c);
+			}
 			break;
 		case Button2:
 			lower(c);
 			break;
 		case Button3:
-			resizemouse(c);
+			if(arrange == dofloat || c->isfloat) {
+				higher(c);
+				resizemouse(c);
+			}
 			break;
 		}
 	}
@@ -197,7 +212,7 @@ configurerequest(XEvent *e)
 		if(ev->value_mask & CWBorderWidth)
 			c->border = 1;
 		gravitate(c, False);
-		resize(c, True);
+		resize(c, True, TopLeft);
 	}
 
 	wc.x = ev->x;
diff --git a/main.c b/main.c
index e8577fe..de59244 100644
--- a/main.c
+++ b/main.c
@@ -24,7 +24,7 @@ static void
 cleanup()
 {
 	while(sel) {
-		resize(sel, True);
+		resize(sel, True, TopLeft);
 		unmanage(sel);
 	}
 	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
diff --git a/tag.c b/tag.c
index 077c93c..1bfedb2 100644
--- a/tag.c
+++ b/tag.c
@@ -45,7 +45,7 @@ dofloat(Arg *arg)
 	for(c = clients; c; c = c->next) {
 		setgeom(c);
 		if(c->tags[tsel]) {
-			resize(c, True);
+			resize(c, True, TopLeft);
 		}
 		else
 			ban(c);
@@ -81,7 +81,7 @@ dotile(Arg *arg)
 		if(c->tags[tsel]) {
 			if(c->isfloat) {
 				higher(c);
-				resize(c, True);
+				resize(c, True, TopLeft);
 				continue;
 			}
 			if(n == 1) {
@@ -102,7 +102,7 @@ dotile(Arg *arg)
 				*c->w = w - 2 * c->border;
 				*c->h = h - 2 * c->border;
 			}
-			resize(c, False);
+			resize(c, False, TopLeft);
 			i++;
 		}
 		else
8bc71d1'>^
9013eaa ^



89b30a6 ^
e1c5a42 ^
89b30a6 ^
e1c5a42 ^
89b30a6 ^

fd7d36f ^
89b30a6 ^

e1c5a42 ^
9013eaa ^


e1c5a42 ^

fd7d36f ^
690a1c3 ^
fd7d36f ^




690a1c3 ^






fd7d36f ^






2b3e09c ^
21b1583 ^
bc464fe ^
e1c5a42 ^
fd7d36f ^
e1c5a42 ^
fd7d36f ^
d141822 ^





e1c5a42 ^







21b1583 ^



e1c5a42 ^

21b1583 ^
bc464fe ^















































21b1583 ^




























































d141822 ^
2b3e09c ^
d141822 ^


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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295