SFML community forums

Help => Window => Topic started by: MickeyKnox on October 04, 2024, 10:18:03 pm

Title: Too many resize events for switch to fullscreen and weird resolution reported
Post by: MickeyKnox on October 04, 2024, 10:18:03 pm
I've created this minimal example:

#include "SFML/Window.hpp"

int main()
{
    sf::Window window(sf::VideoMode(1280, 720), "piv", sf::Style::Default);

    bool fullscreen = false;

    sf::Event event;

    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            switch (event.type)
            {
                case sf::Event::Closed:
                    window.close();
                    break;

                case sf::Event::KeyPressed:
                    switch (event.key.code)
                    {
                        case sf::Keyboard::Escape:
                            window.close();
                            break;

                        case sf::Keyboard::F:
                            printf("toggle fullscreen\n");
                            if (fullscreen)
                            {
                                window.create(sf::VideoMode(1280, 720), "piv", sf::Style::Default);
                                fullscreen = false;
                            }
                            else
                            {
                                window.create(sf::VideoMode::getDesktopMode(), "piv", sf::Style::Fullscreen);
                                fullscreen = true;
                            }
                            break;

                        default:
                            break;
                    }
                    break;

                case sf::Event::Resized:
                    printf("%d %d\n", event.size.width, event.size.height);
                    break;

                default:
                    break;
            }
        }
    }
}
 

And this is the output:

Quote
1280 720
toggle fullscreen
1920 1080
1920 1043
1920 1080
toggle fullscreen
1280 720
toggle fullscreen
1920 1080
1920 1043
1920 1080
toggle fullscreen
1280 720

Why are there three resize events when switching to fullscreen?

Why is there an event for this weird resolution of 1920x1043?

Am I doing something funny here?

SFML 2.6.1 on fedora linux.
Title: Re: Too many resize events for switch to fullscreen and weird resolution reported
Post by: eXpl0it3r on October 06, 2024, 12:12:05 am
SFML just tells the X11 to change the resolution. Not sure what happens exactly on your system then. Maybe the window manager decides to pick a size that doesn't include your taskbar or similar.

Are you running wayland?
What's your window manager?
Title: Re: Too many resize events for switch to fullscreen and weird resolution reported
Post by: MickeyKnox on October 06, 2024, 01:26:00 am
Quote
Are you running wayland?
What's your window manager?

Gnome 46.5 on Wayland (Fedora 40 Workstation)
Title: Re: Too many resize events for switch to fullscreen and weird resolution reported
Post by: MickeyKnox on October 16, 2024, 06:59:28 pm
Has anybody tried to reproduce this problem?

Could you kindly run above code snippet and post the output?

Is this happening on Windows too? Or just on Linux? Or is it just my machine doing something very weird?
Title: Re: Too many resize events for switch to fullscreen and weird resolution reported
Post by: Hapax on October 19, 2024, 06:03:12 pm
Does this have the same effect if you use
getFullscreenModes()[0u]
instead of
getDesktopMode()
?