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

Author Topic: Too many resize events for switch to fullscreen and weird resolution reported  (Read 1601 times)

0 Members and 1 Guest are viewing this topic.

MickeyKnox

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11018
    • View Profile
    • development blog
    • Email
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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MickeyKnox

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Quote
Are you running wayland?
What's your window manager?

Gnome 46.5 on Wayland (Fedora 40 Workstation)

MickeyKnox

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
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?

Hapax

  • Hero Member
  • *****
  • Posts: 3382
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Does this have the same effect if you use
getFullscreenModes()[0u]
instead of
getDesktopMode()
?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything