Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Window Resizing on OS X and Linux  (Read 2646 times)

0 Members and 1 Guest are viewing this topic.

Manuel

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Window Resizing on OS X and Linux
« on: August 07, 2013, 03:02:49 am »
I came up with a simple solution to keep the aspect ratio of my window correct, even if the user choses to manually resize the window. This I am doing by resizing the window to the proper aspect ratio once the resize event fires (user has released the mouse button). This has worked well under OS X and Windows for SFML 2.0.

Sadly with SFML 2.1 it stopped working under OS X ( 10.6 - 10.8) , it still works under Windows as intended. (Tested Versions 7, 8 and XP x64 & x86)

Under Windows it works. The user resizes the window. It resizes itself again to the nearest matching aspect correct size and then then stops. This all happens within a couple of milliseconds, barely noticeable.

Under OS X It resizes several times a second, very quickly the window jittering between various sizes. After some time it settles on a (correct aspect) size. I have noticed that it seems to fire the window::Resized event during OS X resizing animation. Could this be the culprit?

Under Linux (Ubuntu x64), the event seems to fire properly but it does not resize the window. i.e. the size remains unchanged from after the user input. (e.g. squashed)

The main part of the code is basically this:
       
//Window Resized?
if ( event.type == sf::Event::Resized )
{
        //The Window was Resized - Maintain Aspect Ratio
        float AspectX = (float)window.getSize().x / 800.0f;
        float AspectY = (float)window.getSize().y / 600.0f;
               
        //Find Which Is the smaller aspect
        if ( AspectX < AspectY )
        {
                //Resize Y To Fit
                sf::Vector2u tempSize = sf::Vector2u( window.getSize().x, (int)(AspectX * 600.0f) );
                window.setSize( tempSize );
        }
        else if ( AspectX > AspectY )
        {
                //Resize X To Fit
                sf::Vector2u tempSize = sf::Vector2u( (int)(AspectY * 800.0f), window.getSize().y );
                window.setSize( tempSize );
        }
}
 

Is this a bad idea?
Are there more elegant ways to do this? A work around to the issue?

I have also attached a minimum example based on my application that reproduces the problem.

Do you think it is possible to devise a work around until the issue is fixed?

Edit: Tried the latest nightly SFML build, still the issue persists.
« Last Edit: August 07, 2013, 03:34:38 am by Manuel »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Window Resizing on OS X and Linux
« Reply #1 on: August 26, 2013, 08:00:24 pm »
Very interesting bug !  ;D

Would you mind opening an issue on github ? I'll look into it for SFML 2.2. (Until then, I'm afraid you have to find a workaround.. sorry about that.)
SFML / OS X developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Window Resizing on OS X and Linux
« Reply #2 on: September 20, 2013, 10:37:48 pm »
It should be better now.
SFML / OS X developer