1
Window / Linux: occasional white bar on top of fullscreen window
« on: November 21, 2023, 11:09:32 am »
Dear all!
For some time, I've been wrestling with an annoying bug when running my SFML Program on Linux. When switching to fullscreen mode, I do at times get a white bar at the top of the screen. I have seen one bug report which has similar content: https://gitlab.gnome.org/GNOME/mutter/-/issues/2937
I tried every trick I could think of to find the place where things go wrong, but came to conclude that the windowing system messes with the window 'from the outside', because I do get Resize events with the wrong size (desktop height minus the white bar) without having triggered anything along these lines - the window is created with Fullscreen style. I use the Resize event to 'notice' that the bug is happening (it only occurs occasionally) and then I immediately re-create the window with fullscreen style. Usually one detect-recreate cycle is enough, but at times, the system is 'obstinate' and sends a few wrong Resize events before yielding to my re-creates. This produces a bit of flicker, but at least the erroneous state does not persist. I post here in case anyone else is having the same problem. Maybe my workaround can help, until there is a fix system-side which makes it unnecessary. Of course, a 'real' bug fix would be much appreciated!
This is the gist of my worlk-around code:
For some time, I've been wrestling with an annoying bug when running my SFML Program on Linux. When switching to fullscreen mode, I do at times get a white bar at the top of the screen. I have seen one bug report which has similar content: https://gitlab.gnome.org/GNOME/mutter/-/issues/2937
I tried every trick I could think of to find the place where things go wrong, but came to conclude that the windowing system messes with the window 'from the outside', because I do get Resize events with the wrong size (desktop height minus the white bar) without having triggered anything along these lines - the window is created with Fullscreen style. I use the Resize event to 'notice' that the bug is happening (it only occurs occasionally) and then I immediately re-create the window with fullscreen style. Usually one detect-recreate cycle is enough, but at times, the system is 'obstinate' and sends a few wrong Resize events before yielding to my re-creates. This produces a bit of flicker, but at least the erroneous state does not persist. I post here in case anyone else is having the same problem. Maybe my workaround can help, until there is a fix system-side which makes it unnecessary. Of course, a 'real' bug fix would be much appreciated!
This is the gist of my worlk-around code:
...
if ( event.type == sf::Event::Resized )
{
auto window_size = p_window->getSize() ;
if ( ui::run_fullscreen
&& ( window_size.y != desktop.height ) )
{
ui::p_screen->p_window->create ( desktop ,
std::string ( "" ) ,
sf::Style::Fullscreen ) ;
}