SFML community forums

Help => Window => Topic started by: trilavia on December 24, 2012, 03:32:54 pm

Title: setPosition and getPosition don't work correctly on linux
Post by: trilavia on December 24, 2012, 03:32:54 pm
So, I use lubuntu 12.10, the window manager is openbox. Code:



#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
 sf::RenderWindow window(sf::VideoMode(1400, 900), "Bug");
window.setPosition(sf::Vector2i(sf::VideoMode::getDesktopMode().width / 2 - window.getSize().x / 2, 80));
std::cout << window.getPosition().x; //gives 1
std::cout <<  window.getPosition().y; //gives 26

 while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

}
 

My resolution is 1920x1080, so it should be x = 260. Of course, the position isn't updated on screen as well.
Title: Re: setPosition and getPosition don't work correctly on linux
Post by: Laurent on December 24, 2012, 03:40:34 pm
You could have debugged it a bit further, and printed sf::VideoMode::getDesktopMode().width and window.getSize().x to see which one has not the expected value and produces a "1" instead of a "260".
If they both are correct, then it's clearly a bug in the implementation of setPosition.
Title: Re: setPosition and getPosition don't work correctly on linux
Post by: trilavia on December 24, 2012, 04:19:09 pm
sf::VideoMode::getDesktopMode().width = 1920
window.getSize().x = 1400

Both are correct. I use github version of SFML, I think its max 2 days old.

What's more, even if I don't change window position, the window.getPosition().x is 1 and the window.getPosition().y is 26. (of course, the window is by default placed somewhere in the middle of screen, so they are wrong)