Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Event::Close not fired in fullscreen mode.  (Read 1892 times)

0 Members and 1 Guest are viewing this topic.

u

  • Newbie
  • *
  • Posts: 3
    • View Profile
sf::Event::Close not fired in fullscreen mode.
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: sf::Event::Close not fired in fullscreen mode.
« Reply #1 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
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::Event::Close not fired in fullscreen mode.
« Reply #2 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

u

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: sf::Event::Close not fired in fullscreen mode.
« Reply #3 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