I'm sorry for resurrecting an old thread; I believe it's still relevant, however, as the problem still exists. (I'm aware that this is being fixed in the library)
I ended up on this thread because I was having this problem too. I came back because I found a simple workaround. It may be bad practice but it seems to work until the fix is applied.
This is for Windows only. You'll also need to #include <Windows.h>
If, in your main loop, you put the code:
SetForegroundWindow(renderWindow.getSystemHandle());
with "renderWindow" being your RenderWindow object, it should allow you to click the client area to refocus the window. Oddly, it doesn't actually set the focus of the window or activate it by itself as it is supposed to.
I hope this helps for now. I'm looking forward to the new version of SFML (hopefully with a VS2013 build as my build seemed to fail at creating debug libraries :( )
So you're mixing SFML with your own GTK+ windows?
What if you just used like the simplest example:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window{{1024, 768}, "Test"};
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.display();
}
}
So you're mixing SFML with your own GTK+ windows?
What if you just used like the simplest example:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window{{1024, 768}, "Test"};
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.display();
}
}
I just tried your simple example. When I ran the code exactly as you have it, I got an error about extended initializer lists being only available with -std=c++11. I modified the sf::RenderWindow line to instead read:
sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
as per the tutorial page on using the SFML graphics package. This modification makes the simple example run correctly. However, the window still suffers from the same problem as before. The window does not regain focus by clicking in the body of the window.