LaurentGomila/SFML — pull request #613 by Bromeon (2014-05-24 14:34:40+00:00)
Title: Methods to request and check window focus

This pull request is based on https://github.com/LaurentGomila/SFML/pull/525 by @Foaly.

It extends the `sf::Window` public interface with two methods:
* `void requestFocus()` to give the window the focus
* `bool hasFocus() const` to check whether the window is currently focused

I tested the functionality on Windows 8.1 and Ubuntu 12.04. Here's a simple test program, based on Foaly's:
```cpp
#include

int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
window.setFramerateLimit(60);

sf::Clock clock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Escape)
window.close();
}

if (clock.getElapsedTime() > sf::seconds(2))
{
window.requestFocus();
clock.restart();
}

window.setTitle(window.hasFocus() ? "Focused" : "Lost");
window.clear(window.hasFocus() ? sf::Color::White : sf::Color::Black);
window.display();
}
}
```

I haven't gotten feedback concerning the X11 check as suggested by @FRex, it would be nice if somebody could have a look at commit 2df07b2eb61a9603bedb095dff73a042c4f26453.