We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4373

Summary: SDL_WINDOW_ALLOW_HIGHDPI flag is not unset on failure
Product: SDL Reporter: Caleb Cornett <spydog>
Component: videoAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72, sezeroz
Version: 2.0.9   
Hardware: x86_64   
OS: Mac OS X (All)   

Description Caleb Cornett 2018-11-09 02:58:31 UTC
On macOS, if SDL cannot create a high-DPI window (e.g. because of an insufficient screen resolution), the SDL_WINDOW_ALLOW_HIGHDPI window flag is never turned off. This makes it difficult to determine at runtime if high-dpi window creation has been successful.

The snippet responsible for this behavior (or lack thereof) appears to be this:
https://hg.libsdl.org/SDL/file/a4d730631698/src/video/cocoa/SDL_cocoawindow.m#l1360

What's the best way to fix this? I suspect there's a simple solution, but I'm not familiar with Cocoa so I have no idea what it would be.
Comment 1 Alex Szpakowski 2018-11-09 12:11:21 UTC
As the flag's name implies, it just makes SDL windows capable of being high-dpi, it isn't really meant to fail to create the window if it isn't high dpi - you can use SDL_GL_GetDrawableSize (if you're using OpenGL directly), or SDL_GetRendererOutputSize (if you're using SDL_Render) and compare that to SDL_GetWindowSize, to determine if the window is currently high dpi.