Hi, I'm using Linux (Ubuntu Trusty) with fluxbox (1.3.5) as window manager. When alt-tab'ing, my program behaves weird referring to GainFocus and LostFocus. Here's the Code:
#include <iostream>
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(320, 240), "Test");
window.clear();
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed:
window.close();
break;
case sf::Event::LostFocus:
std::cout << "Focus Lost" << std::endl;
break;
case sf::Event::GainedFocus:
std::cout << "Focus Gained" << std::endl;
break;
default:
break;
}
}
window.display();
}
}
- On startup it gains focus (ok).
- Alt-Tab'ing to unfocus the window causes "Lost, Gained, Lost, Lost"
- Alt-Tab'ing to refocus the window causes "Gained, Gained"
I think that's weird! Is the problem fluxbox's fault?
I also attached a very short video showing that the behavior can be reproduced.
Kind regards
/EDIT: Changing focus by clicking behaves as expected. Closing by Alt-F4 causes "Lost, Lost, Gained".