diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-03-01 12:33:45 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-03-01 12:33:45 +0100 |
| commit | 9ca5c3b108dbda55c1ac9f068b631911f5685eeb (patch) | |
| tree | 64eb004da5a376ff0145b4bae2643a373d728e3e /client.c | |
| parent | removed sendevent (diff) | |
| download | dwm-9ca5c3b108dbda55c1ac9f068b631911f5685eeb.tar.gz dwm-9ca5c3b108dbda55c1ac9f068b631911f5685eeb.zip | |
some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Diffstat (limited to '')
| -rw-r--r-- | client.c | 39 |
1 files changed, 23 insertions, 16 deletions
| @@ -227,35 +227,26 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 227 | 227 | ||
| 228 | void | 228 | void |
| 229 | resize(Client *c, int x, int y, int w, int h, Bool sizehints) { | 229 | resize(Client *c, int x, int y, int w, int h, Bool sizehints) { |
| 230 | float actual, dx, dy, max, min; | 230 | float dx, dy, max, min, ratio; |
| 231 | XWindowChanges wc; | 231 | XWindowChanges wc; |
| 232 | 232 | ||
| 233 | if(w <= 0 || h <= 0) | 233 | if(w <= 0 || h <= 0) |
| 234 | return; | 234 | return; |
| 235 | if(sizehints) { | 235 | if(sizehints) { |
| 236 | if(c->minw && w < c->minw) | ||
| 237 | w = c->minw; | ||
| 238 | if(c->minh && h < c->minh) | ||
| 239 | h = c->minh; | ||
| 240 | if(c->maxw && w > c->maxw) | ||
| 241 | w = c->maxw; | ||
| 242 | if(c->maxh && h > c->maxh) | ||
| 243 | h = c->maxh; | ||
| 244 | /* inspired by algorithm from fluxbox */ | ||
| 245 | if(c->minay > 0 && c->maxay && (h - c->baseh) > 0) { | 236 | if(c->minay > 0 && c->maxay && (h - c->baseh) > 0) { |
| 246 | dx = (float)(w - c->basew); | 237 | dx = (float)(w - c->basew); |
| 247 | dy = (float)(h - c->baseh); | 238 | dy = (float)(h - c->baseh); |
| 248 | min = (float)(c->minax) / (float)(c->minay); | 239 | min = (float)(c->minax) / (float)(c->minay); |
| 249 | max = (float)(c->maxax) / (float)(c->maxay); | 240 | max = (float)(c->maxax) / (float)(c->maxay); |
| 250 | actual = dx / dy; | 241 | ratio = dx / dy; |
| 251 | if(max > 0 && min > 0 && actual > 0) { | 242 | if(max > 0 && min > 0 && ratio > 0) { |
| 252 | if(actual < min) { | 243 | if(ratio < min) { |
| 253 | dy = (dx * min + dy) / (min * min + 1); | 244 | dy = (dx * min + dy) / (min * min + 1); |
| 254 | dx = dy * min; | 245 | dx = dy * min; |
| 255 | w = (int)dx + c->basew; | 246 | w = (int)dx + c->basew; |
| 256 | h = (int)dy + c->baseh; | 247 | h = (int)dy + c->baseh; |
| 257 | } | 248 | } |
| 258 | else if(actual > max) { | 249 | else if(ratio > max) { |
| 259 | dy = (dx * min + dy) / (max * max + 1); | 250 | dy = (dx * min + dy) / (max * max + 1); |
| 260 | dx = dy * min; | 251 | dx = dy * min; |
| 261 | w = (int)dx + c->basew; | 252 | w = (int)dx + c->basew; |
| @@ -263,6 +254,14 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { | |||
| 263 | } | 254 | } |
| 264 | } | 255 | } |
| 265 | } | 256 | } |
| 257 | if(c->minw && w < c->minw) | ||
| 258 | w = c->minw; | ||
| 259 | if(c->minh && h < c->minh) | ||
| 260 | h = c->minh; | ||
| 261 | if(c->maxw && w > c->maxw) | ||
| 262 | w = c->maxw; | ||
| 263 | if(c->maxh && h > c->maxh) | ||
| 264 | h = c->maxh; | ||
| 266 | if(c->incw) | 265 | if(c->incw) |
| 267 | w -= (w - c->basew) % c->incw; | 266 | w -= (w - c->basew) % c->incw; |
| 268 | if(c->inch) | 267 | if(c->inch) |
| @@ -313,6 +312,10 @@ updatesizehints(Client *c) { | |||
| 313 | c->basew = size.base_width; | 312 | c->basew = size.base_width; |
| 314 | c->baseh = size.base_height; | 313 | c->baseh = size.base_height; |
| 315 | } | 314 | } |
| 315 | else if(c->flags & PMinSize) { | ||
| 316 | c->basew = size.min_width; | ||
| 317 | c->baseh = size.min_height; | ||
| 318 | } | ||
| 316 | else | 319 | else |
| 317 | c->basew = c->baseh = 0; | 320 | c->basew = c->baseh = 0; |
| 318 | if(c->flags & PResizeInc) { | 321 | if(c->flags & PResizeInc) { |
| @@ -331,16 +334,20 @@ updatesizehints(Client *c) { | |||
| 331 | c->minw = size.min_width; | 334 | c->minw = size.min_width; |
| 332 | c->minh = size.min_height; | 335 | c->minh = size.min_height; |
| 333 | } | 336 | } |
| 337 | else if(c->flags & PBaseSize) { | ||
| 338 | c->minw = size.base_width; | ||
| 339 | c->minh = size.base_height; | ||
| 340 | } | ||
| 334 | else | 341 | else |
| 335 | c->minw = c->minh = 0; | 342 | c->minw = c->minh = 0; |
| 336 | if(c->flags & PAspect) { | 343 | if(c->flags & PAspect) { |
| 337 | c->minax = size.min_aspect.x; | 344 | c->minax = size.min_aspect.x; |
| 338 | c->minay = size.min_aspect.y; | ||
| 339 | c->maxax = size.max_aspect.x; | 345 | c->maxax = size.max_aspect.x; |
| 346 | c->minay = size.min_aspect.y; | ||
| 340 | c->maxay = size.max_aspect.y; | 347 | c->maxay = size.max_aspect.y; |
| 341 | } | 348 | } |
| 342 | else | 349 | else |
| 343 | c->minax = c->minay = c->maxax = c->maxay = 0; | 350 | c->minax = c->maxax = c->minay = c->maxay = 0; |
| 344 | c->isfixed = (c->maxw && c->minw && c->maxh && c->minh | 351 | c->isfixed = (c->maxw && c->minw && c->maxh && c->minh |
| 345 | && c->maxw == c->minw && c->maxh == c->minh); | 352 | && c->maxw == c->minw && c->maxh == c->minh); |
| 346 | } | 353 | } |
