Hi again,
In resize(), dwm tries to check, with the condition c->mina > (float) h/w,
if a window's aspect is less than its stated minimum aspect. Since mina
and h/w are not actually aspects but their reciprocals, the > sign needs
to be a <. (Try it with mplayer.)
Is there a reason though for mina being y/x ratio instead of x/y, maybe
some tricky floating point accuracy business? If not, I'd suggest changing
the aspect code along the lines of the patch attached.
Another problem is that in case of a window with a min size and no base
size, basew/baseh is set to the value of minw/minh. Unfortunately, the
ICCCM (4.1.2.3*, last two sentences) forbids subtracting the min size
before aspect ratio calculation. This skews calculating the aspect for
mplayer windows (4x4 min size) a little. I'm not sure how to fix it though
without turning the code into a mess...
* http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.3
Regards,
Peter
diff -r c4ecef7983b8 dwm.c
--- a/dwm.c Mon Aug 18 19:28:34 2008 +0100
+++ b/dwm.c Tue Aug 19 18:46:22 2008 +0200
@@ -1046,6 +1046,7 @@
void
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
+ float a;
XWindowChanges wc;
if(sizehints) {
@@ -1059,10 +1060,11 @@
/* adjust for aspect limits */
if(c->mina > 0 && c->maxa > 0) {
- if(c->maxa < (float) w/h)
+ a = (float) w/h;
+ if(a > c->maxa)
w = h * c->maxa;
- else if(c->mina > (float) h/w)
- h = w * c->mina;
+ else if(a < c->mina)
+ h = w / c->mina;
}
/* adjust for increment value */
@@ -1602,7 +1604,7 @@
else
c->minw = c->minh = 0;
if(size.flags & PAspect) {
- c->mina = (float)size.min_aspect.y / (float)size.min_aspect.x;
+ c->mina = (float)size.min_aspect.x / (float)size.min_aspect.y;
c->maxa = (float)size.max_aspect.x / (float)size.max_aspect.y;
}
else