title: Undefined reference to sf::Window::hasFocus?
body: <h1>Question</h1>
  <p>SFML windows implement the method <code>hasFocus()</code> as a convenient way of checking whether the window has focus or is a background window.</p>
  <p>It seems strange to me that this method does not appear to be implemented for <code>sf::RenderWindow</code>'s, particularly as the following code compiles, but does not link. (Perhaps this is a bug or an oversight of the developer? If so it might be an idea to implement this in the next set of bug fixes.)</p>
  <p>Code example:</p>
  <pre><code>sf::RenderWindow window;
  
  while(window.isOpen())
  {
  
      if(window.hasFocus())
      {
          // do something
      }
  
      window.clear();
      // etc drawing code
  }
  </code></pre>
  <p>This compiles, using: <code>g++ --std=c++11 main.cpp -o ratwatch -lsfml-graphics -lsfml-window -lsfml-system</code></p>
  <p>but unfortunately will not link, with the following error:</p>
  <pre><code>/tmp/ccWhfqtT.o: In function `main':
  main.cpp:(.text+0xc3b): undefined reference to `sf::Window::hasFocus() const'
  collect2: error: ld returned 1 exit status
  </code></pre>
  <p>Have I made a mistake with my linking libraries? Did I miss another <code>-lsfml...</code>?</p>
  <h1>Workaround</h1>
  <p>I managed to do what I was trying to do wit the following code, but this is clearly a messy and unnecessarily convoluted workaround:</p>
  <pre><code>sf::RenderWindow window(sf::VideoMode(800, 600), &quot;text&quot;);
  bool WINDOW_HAS_FOCUS = false;
  
  while(window.isOpen())
  {
  
      sf::Event event;
      while(window.pollEvent(event))
      {
  
          if(event.type == sf::Event::LostFocus)
          {
              WINDOW_HAS_FOCUS = false;
          }
          else if(event.type == sf::Event::GainedFocus)
          {
              WINDOW_HAS_FOCUS = true;
          }
  
      }
  
      // ... later in program ...
  
      if(WINDOW_HAS_FOCUS)
      {
          // do something
      }
  
      window.clear();
      // etc drawing code
  }
  </code></pre>
  <p>Hope that's helpful to anyone who wasn't able to do what I was trying to, if a solution to my original question cannot be found.</p>