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

Author Topic: Setting window visibility off/on causes strange (?) behaviour on Linux  (Read 4092 times)

0 Members and 1 Guest are viewing this topic.

Slashcash

  • Newbie
  • *
  • Posts: 2
    • View Profile
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:


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



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.
« Last Edit: January 06, 2018, 01:36:27 pm by Slashcash »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Setting window visibility off/on causes strange (?) behaviour on Linux
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Setting window visibility off/on causes strange (?) behaviour on Linux
« Reply #2 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?
« Last Edit: January 06, 2018, 09:55:22 pm by dabbertorres »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Setting window visibility off/on causes strange (?) behaviour on Linux
« Reply #3 on: January 07, 2018, 12:54:05 am »
Sure, go ahead. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Slashcash

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Setting window visibility off/on causes strange (?) behaviour on Linux
« Reply #4 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!

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog

 

anything