SFML/SFML

`sf::VideoMode::getDesktopMode()` returning the monitor resolution on macOS

alihakankurt opened this issue · 2 comments

Prerequisite Checklist

Describe your issue here

My monitor resolution is 3420x2224 and my screen resolution is set to 1720x1112. The sf::VideoMode::getDesktopMode() is returning the correct screen resolution on Windows but it's returning the monitor resolution on macOS (in my case 3420x2224). I think it's related to the scaleOutXY function in the cf_sf_conversion.mm file because the CGDisplayModeGetWidth() and CGDisplayModeGetWidth() functions returning the correct screen resolution values.

Your Environment

  • OS / distro / window manager: macOS Ventura 13.5.1
  • SFML version: 3.0.0
  • Compiler / toolchain: Apple clang version 15..0.0 (clang-1500.1.0.2.5)
  • Special compiler / CMake flags:

Steps to reproduce

#include <SFML/Graphics.hpp>

int main()
{
    const sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
    const unsigned int width = desktop.size.x / 2;
    const unsigned int height = desktop.size.y / 2;

    // The windows goes out of screen because of wrong screen resolution.
    sf::RenderWindow window(sf::VideoMode({width, height}), "Minimal, complete and verifiable example");
    window.setFramerateLimit(60);

    while (window.isOpen())
    {
        for (sf::Event event; window.pollEvent(event);)
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

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

Expected behavior

The sf::VideoMode::getDesktopMode() should have return the screen resolution which is set by user.

Actual behavior

The sf::VideoMode::getDesktopMode() returned the monitor resolution independently from screen resolution.

Have you read #2300 yet? If not then please read through that thread so you can get caught up with our progress on fixing this problem. I'm the SFML maintainer who uses macOS so I'm the one to talk to about fixing this. I'm eager to fix it but so far nobody is totally sure what the right fix is.

I checked the current issues to prevent duplication. I saw that issue and I don't think it's related to the my problem. The sf::VideoMode::getFullscreenModes() also returning empty and causing segfault but my problem is inconsistency between Windows and macOS platforms. sf:: VideoMode::getDesktopMode() returning the user set screen resolution on Windows, but on macOS it's returning the monitor resolution (or the full screen resolution). I as described above, when I remove the scaleOutXY function from source code, it's returning the correct values of my custom screen resolution.