SFML community forums

Help => Window => Topic started by: Glocke on February 24, 2015, 03:25:15 pm

Title: [Linux with Fluxbox] Weird Focus Gain/Lose on Alt-Tab / Alt-F4
Post by: Glocke on February 24, 2015, 03:25:15 pm
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();
        }
}


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".
Title: Re: Weird Focus Gain/Lose on Alt-Tab / Alt-F4
Post by: Laurent on February 24, 2015, 03:33:04 pm
Would be great if you of someone else could test the same thing with another WM.
Title: Re: Weird Focus Gain/Lose on Alt-Tab / Alt-F4
Post by: Glocke on February 24, 2015, 03:47:42 pm
A friend of mine just tested it with the Gnome Desktop: Alt-Tab works as expected, but moving the window around triggers events. Moving the window inside fluxbox doesn't.
Title: AW: [Linux with Fluxbox] Weird Focus Gain/Lose on Alt-Tab / Alt-F4
Post by: eXpl0it3r on February 24, 2015, 08:58:15 pm
What version of SFML are you using?
Does the following PR change anything? https://github.com/SFML/SFML/pull/780
Title: Re: [Linux with Fluxbox] Weird Focus Gain/Lose on Alt-Tab / Alt-F4
Post by: Jesper Juhl on February 24, 2015, 09:44:34 pm
I just tested the posted example code on my system (CentOS 7 with xfce4) and it behaves reasonably OK although it's slightly odd that whenever I "ALT-tab" away from the program window I get 2 FocusLost events and when I "ALT-tab" back I get 2 FocusGained events. I would have expected 1 event in each case.
Title: Re: AW: [Linux with Fluxbox] Weird Focus Gain/Lose on Alt-Tab / Alt-F4
Post by: Glocke on February 25, 2015, 08:26:34 am
What version of SFML are you using?
2.2

Does the following PR change anything? https://github.com/SFML/SFML/pull/780
Haven't tested yet. I don't have the time to recompile SFML, yet :(
Title: Re: [Linux with Fluxbox] Weird Focus Gain/Lose on Alt-Tab / Alt-F4
Post by: eXpl0it3r on February 25, 2015, 09:03:18 am
If you use 2.2 you might want to try the latest master since we switched to XCB.
Title: Re: [Linux with Fluxbox] Weird Focus Gain/Lose on Alt-Tab / Alt-F4
Post by: Glocke on February 25, 2015, 10:10:05 am
If you use 2.2 you might want to try the latest master since we switched to XCB.

Well, I just pulled, installed all missing dev-packages, compiled sfml, recompiled my test code with using the new headers and shared objects, but the behavior is still weird :S

/EDIT: Just tested "Openbox": Gain Focus works as expected but Lose Focus causes "Gain, Lose, Gain, Lose"