SFML community forums

Help => Window => Topic started by: Slashcash on January 06, 2018, 01:22:28 pm

Title: Setting window visibility off/on causes strange (?) behaviour on Linux
Post by: Slashcash on January 06, 2018, 01:22:28 pm
Setting the visibility off and then back on for a fullscreen window causes a strange behaviour: just before setting the visibility off (with setVisible) the fullscreen window is shiny and glorious. When i set it off and then back on again when i need it the window is shown again but with a titlebar and not in a fullscreen mode.

Is this the intended behaviour? Am i doing something wrong? I'm trying to achieve an unrealistic thing? Any workaround on this?
It is happening on my Kubuntu box with KDE

this is a minimal snippet of compilable code that reproduces the problem

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(1920, 1080), "SFML works!", sf::Style::Fullscreen);
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) window.close();
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::A) { window.setVisible(false); window.setVisible(true); }
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

Just before changing the visibility of the window:
(https://i.imgur.com/z6kHn0P.png)

Right after :( (please note the titlebar and the task bar showing)

(https://i.imgur.com/4a4Q5fi.png)

I'm not even sure if it is SFML's fault or if it's KDE messing things up and i'm unable to test it on other machines at the moment.
Title: Re: Setting window visibility off/on causes strange (?) behaviour on Linux
Post by: eXpl0it3r on January 06, 2018, 05:19:53 pm
When you're in fullscreen you don't really have a "window" as such one could argue that changing the window's visibility may be questionable.
However since it's not documented to not work for fullscreen "windows", I'm not sure what the expected behavior should be.

For Linux, since it's a rarely used function, it might well be, that it wasn't implemented quite right. When making it visible again, one probably would have to send some event to make it fullscreen again.
Title: Re: Setting window visibility off/on causes strange (?) behaviour on Linux
Post by: dabbertorres on January 06, 2018, 09:51:37 pm
I can confirm this happens on i3 on Arch Linux.

I made a small change in SFML that corrected the behavior for me.
(click to show/hide)

Slashcash, would you mind checking if it fixes it for you? https://github.com/dabbertorres/SFML/tree/unix-window-fullscreen

If it does, eXpl0it3r, can I go ahead and make a PR for it?
Title: Re: Setting window visibility off/on causes strange (?) behaviour on Linux
Post by: eXpl0it3r on January 07, 2018, 12:54:05 am
Sure, go ahead. :)
Title: Re: Setting window visibility off/on causes strange (?) behaviour on Linux
Post by: Slashcash on January 07, 2018, 02:00:26 am
Slashcash, would you mind checking if it fixes it for you? https://github.com/dabbertorres/SFML/tree/unix-window-fullscreen

I can confirm this fixes the issue here too!
Title: Re: Setting window visibility off/on causes strange (?) behaviour on Linux
Post by: dabbertorres on January 07, 2018, 07:31:34 pm
Great!

PR is here: https://github.com/SFML/SFML/pull/1339