SFML community forums

Help => Window => Topic started by: u on February 11, 2014, 01:09:02 pm

Title: sf::Event::Close not fired in fullscreen mode.
Post by: u on February 11, 2014, 01:09:02 pm
Hi.

I recently started using SFML and it's been a pure pleasure.

One thing I noticed is that windows in full screen mode doesn't seem to fire window close events. Is this the intended behavior?

In the following example it is possible to close the application using the escape key, but it isn't possible to close it using [alt]+[f4]. Notice that using [alt]+[f4] works just fine for windowed applications on the same system.

#include <SFML/Graphics.hpp>

int main(int argc, char **argv) {
        // Open window.
        sf::RenderWindow window(sf::VideoMode(1024, 768), "untitled", sf::Style::Fullscreen);

        // Render and event loop.
        while (window.isOpen()) {
                // Poll events until the event queue is empty.
                sf::Event event;
                while (window.pollEvent(event)) {
                        // Window close event.
                        if (event.type == sf::Event::Closed) {
                                window.close();
                        }
                        // The escape key was pressed.
                        if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
                                window.close();
                        }
                }

                // Clear the window with black color.
                window.clear(sf::Color::Black);

                // Display window updates.
                window.display();
        }

        return 0;
}
 

Cheers /u
Title: Re: sf::Event::Close not fired in fullscreen mode.
Post by: eXpl0it3r on February 11, 2014, 01:15:08 pm
If that happens, it's definitely not an intended behavior.

You left out some important information: OS, compiler, etc
Title: Re: sf::Event::Close not fired in fullscreen mode.
Post by: Hapax on February 11, 2014, 03:17:28 pm
I may be wrong but I don't think Windows actually sends "close window" events to an application that is fullscreen rather than in a window. If you're using Windows, that could be the reason.
Title: Re: sf::Event::Close not fired in fullscreen mode.
Post by: u on February 20, 2014, 09:49:43 pm
Hi.

I'm using Arch Linux and GCC. My window manager is Openbox 3.5.2. Below is some more detailed info. If you need more, just ask me :)

[~]$ gcc --version
gcc (GCC) 4.8.2 20140206 (prerelease)

SFML 2.1.0 (4a300547f3)

[~]$ uname -a
Linux x61s 3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014 x86_64 GNU/Linux

[~]$ gcc -o a a.cpp -lstdc++ -lsfml-window -lsfml-system -lsfml-graphics

Regards /u