Mercurial > aewl
comparison client.c @ 732:a642068c4834
simplification
author | Anselm R. Garbe <arg@suckless.org> |
---|---|
date | Tue, 06 Feb 2007 15:28:25 +0100 |
parents | 29c9b557ed95 |
children | 1950833a5614 |
comparison
equal
deleted
inserted
replaced
731:29c9b557ed95 | 732:a642068c4834 |
---|---|
6 #include <string.h> | 6 #include <string.h> |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/Xutil.h> | 8 #include <X11/Xutil.h> |
9 | 9 |
10 /* static */ | 10 /* static */ |
11 | |
12 static void | |
13 closestpt(float *rx, float *ry, float x, float y, float grad) { | |
14 float u = (x * grad + y) / (grad * grad + 1); | |
15 *rx = u * grad; | |
16 *ry = u; | |
17 } | |
18 | 11 |
19 static void | 12 static void |
20 detachstack(Client *c) { | 13 detachstack(Client *c) { |
21 Client **tc; | 14 Client **tc; |
22 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); | 15 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); |
189 arrange(); | 182 arrange(); |
190 } | 183 } |
191 | 184 |
192 void | 185 void |
193 resize(Client *c, Bool sizehints) { | 186 resize(Client *c, Bool sizehints) { |
194 float dx, dy, min, max, actual; | 187 float actual, dx, dy, max, min, u; |
195 XWindowChanges wc; | 188 XWindowChanges wc; |
196 | 189 |
197 if(c->w <= 0 || c->h <= 0) | 190 if(c->w <= 0 || c->h <= 0) |
198 return; | 191 return; |
199 if(sizehints) { | 192 if(sizehints) { |
212 min = (float)(c->minax) / (float)(c->minay); | 205 min = (float)(c->minax) / (float)(c->minay); |
213 max = (float)(c->maxax) / (float)(c->maxay); | 206 max = (float)(c->maxax) / (float)(c->maxay); |
214 actual = dx / dy; | 207 actual = dx / dy; |
215 if(max > 0 && min > 0 && actual > 0) { | 208 if(max > 0 && min > 0 && actual > 0) { |
216 if(actual < min) { | 209 if(actual < min) { |
217 closestpt(&dx, &dy, dx, dy, min); | 210 dy = (dx * min + dy) / (min * min + 1); |
211 dx = dy * min; | |
218 c->w = (int)dx + c->basew; | 212 c->w = (int)dx + c->basew; |
219 c->h = (int)dy + c->baseh; | 213 c->h = (int)dy + c->baseh; |
220 } | 214 } |
221 else if(actual > max) { | 215 else if(actual > max) { |
222 closestpt(&dx, &dy, dx, dy, max); | 216 dy = (dx * min + dy) / (max * max + 1); |
217 dx = dy * min; | |
223 c->w = (int)dx + c->basew; | 218 c->w = (int)dx + c->basew; |
224 c->h = (int)dy + c->baseh; | 219 c->h = (int)dy + c->baseh; |
225 } | 220 } |
226 } | 221 } |
227 } | 222 } |