made resize more precise

This commit is contained in:
Anselm R. Garbe 2007-08-13 18:24:15 +02:00
parent 0937cc78bf
commit 2feb3afe78

View file

@ -235,17 +235,14 @@ manage(Window w, XWindowAttributes *wa) {
void void
resize(Client *c, int x, int y, int w, int h, Bool sizehints) { resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
float dx, dy, max, min, ratio; double dx, dy, max, min, ratio;
XWindowChanges wc; XWindowChanges wc;
if(w <= 0 || h <= 0)
return;
if(sizehints) { if(sizehints) {
if(c->minay > 0 && c->maxay > 0 && (h - c->baseh) > 0) { if(c->minay > 0 && c->maxay > 0 && (h - c->baseh) > 0 && (w - c->basew) > 0) {
dx = (float)(w - c->basew); dx = (double)(w - c->basew);
dy = (float)(h - c->baseh); dy = (double)(h - c->baseh);
min = (float)(c->minax) / (float)(c->minay); min = (double)(c->minax) / (double)(c->minay);
max = (float)(c->maxax) / (float)(c->maxay); max = (double)(c->maxax) / (double)(c->maxay);
ratio = dx / dy; ratio = dx / dy;
if(max > 0 && min > 0 && ratio > 0) { if(max > 0 && min > 0 && ratio > 0) {
if(ratio < min) { if(ratio < min) {
@ -274,9 +271,9 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
w -= (w - c->basew) % c->incw; w -= (w - c->basew) % c->incw;
if(c->inch) if(c->inch)
h -= (h - c->baseh) % c->inch; h -= (h - c->baseh) % c->inch;
if(w <= 0 || h <= 0)
return;
} }
if(w <= 0 || h <= 0)
return;
/* offscreen appearance fixes */ /* offscreen appearance fixes */
if(x > sw) if(x > sw)
x = sw - w - 2 * c->border; x = sw - w - 2 * c->border;