made resize more precise
2feb3afe
1 file(s) · +9 −12
| 235 | 235 | ||
| 236 | 236 | void |
|
| 237 | 237 | resize(Client *c, int x, int y, int w, int h, Bool sizehints) { |
|
| 238 | - | float dx, dy, max, min, ratio; |
|
| 239 | - | XWindowChanges wc; |
|
| 240 | - | ||
| 241 | - | if(w <= 0 || h <= 0) |
|
| 242 | - | return; |
|
| 238 | + | double dx, dy, max, min, ratio; |
|
| 239 | + | XWindowChanges wc; |
|
| 243 | 240 | if(sizehints) { |
|
| 244 | - | if(c->minay > 0 && c->maxay > 0 && (h - c->baseh) > 0) { |
|
| 245 | - | dx = (float)(w - c->basew); |
|
| 246 | - | dy = (float)(h - c->baseh); |
|
| 247 | - | min = (float)(c->minax) / (float)(c->minay); |
|
| 248 | - | max = (float)(c->maxax) / (float)(c->maxay); |
|
| 241 | + | if(c->minay > 0 && c->maxay > 0 && (h - c->baseh) > 0 && (w - c->basew) > 0) { |
|
| 242 | + | dx = (double)(w - c->basew); |
|
| 243 | + | dy = (double)(h - c->baseh); |
|
| 244 | + | min = (double)(c->minax) / (double)(c->minay); |
|
| 245 | + | max = (double)(c->maxax) / (double)(c->maxay); |
|
| 249 | 246 | ratio = dx / dy; |
|
| 250 | 247 | if(max > 0 && min > 0 && ratio > 0) { |
|
| 251 | 248 | if(ratio < min) { |
|
| 274 | 271 | w -= (w - c->basew) % c->incw; |
|
| 275 | 272 | if(c->inch) |
|
| 276 | 273 | h -= (h - c->baseh) % c->inch; |
|
| 274 | + | if(w <= 0 || h <= 0) |
|
| 275 | + | return; |
|
| 277 | 276 | } |
|
| 278 | - | if(w <= 0 || h <= 0) |
|
| 279 | - | return; |
|
| 280 | 277 | /* offscreen appearance fixes */ |
|
| 281 | 278 | if(x > sw) |
|
| 282 | 279 | x = sw - w - 2 * c->border; |
|