Re: [dev] dwm-5.6

From: Szabolcs Nagy <nszabolcs_AT_gmail.com>
Date: Fri, 17 Jul 2009 13:33:54 +0200

On 7/17/09, Szabolcs Nagy <nszabolcs_AT_gmail.com> wrote:
> On 7/16/09, Arun G Nair <arungnair_AT_gmail.com> wrote:
>> I have had a problem since 5.5. And its still there in 5.6. If I try to
>> move
>> the mplayer window its starts to resize and gets smaller and smaller. Am
>> using Alt + Right mouse button to do this. I've commented out
>
> i've noticed the same, but only with movies where 32 does not divide
> its sides, so it seems some rounding problem while mplayer tries to
> keep the aspect ratio (dwm uses floats for that)
>

the problem was that dwm used int cast instead of rounding, so this
modification in applysizehints() solves the problem:

                 /* adjust for aspect limits */
                 if(c->mina > 0 && c->maxa > 0) {
                         if(c->maxa < (float)*w / *h)
- *w = *h * c->maxa;
+ *w = *h * c->maxa + 0.5;
                         else if(c->mina < (float)*h / *w)
- *h = *w * c->mina;
+ *h = *w * c->mina + 0.5;
                 }

one may wonder why the inequalities were true in the first place,
since we calculate mina and maxa from the same w and h so w,h
shouldn't get to be updated at all

it turns out the result of those inequalities depend on compiler
optimization flags (compiler might choose to use double division and
comparison instead of float one) so with -O0 there are no updates,
with -Os there are always updates unless the aspect is a "nice" ratio.

there is an unnecessary float cast in updatesizehints:

         if(size.flags & PAspect) {
- c->mina = (float)size.min_aspect.y / (float)size.min_aspect.x;
- c->maxa = (float)size.max_aspect.x / (float)size.max_aspect.y;
+ c->mina = (float)size.min_aspect.y / size.min_aspect.x;
+ c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
         }

probably dwm should not use floats for aspect..
Received on Fri Jul 17 2009 - 11:33:54 UTC

This archive was generated by hypermail 2.2.0 : Fri Jul 17 2009 - 11:36:02 UTC