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

Author Topic: setPosition and getPosition don't work correctly on linux  (Read 1152 times)

0 Members and 1 Guest are viewing this topic.

trilavia

  • Newbie
  • *
  • Posts: 28
    • View Profile
setPosition and getPosition don't work correctly on linux
« 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.
« Last Edit: December 24, 2012, 03:35:00 pm by trilavia »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: setPosition and getPosition don't work correctly on linux
« Reply #1 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.
Laurent Gomila - SFML developer

trilavia

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: setPosition and getPosition don't work correctly on linux
« Reply #2 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)
« Last Edit: December 24, 2012, 04:23:12 pm by trilavia »

 

anything