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 3607 - When SDL_WINDOW_ALLOW_HIGHDPI is set, resize events/SDL_GetWindowSize give scaled size
Summary: When SDL_WINDOW_ALLOW_HIGHDPI is set, resize events/SDL_GetWindowSize give sc...
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.4
Hardware: x86 macOS 10.12
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-16 03:59 UTC by Mark Callow
Modified: 2017-03-25 09:38 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Callow 2017-03-16 03:59:44 UTC
When SDL_WINDOW_ALLOW_HIGHDPI is set, width and height in SDL_WINDOWEVENT_SIZE_CHANGED events and returned by SDL_GetWindowSize() are the scaled size of the window not the high DPI size of the window.

E.g on my iPad Pro with these return a size of 1024 x 1366 regardless of whether SDL_WINDOW_ALLOW_HIGHDPI is set. When it is set, the size returned by SDL_GL_GetDrawableSize is 2048 x 2732.

When SDL_WINDOW_ALLOW_HIGHDPI is set, I think all window size information should be actual size.

Among other problems this is likely the cause of bug #2565.
Comment 1 Mark Callow 2017-03-16 05:18:51 UTC
Internally SDL_SendWindowEvent sets the value reported by SDL_GetWindowSize() as well as sending the DL_WINDOWEVENT_SIZE_CHANGED event. For uikit video, this is called by uikitviewcontroller.viewDidLayoutSubviews and it passes the size of the bounds of the controller's main view. UIView bounds are always in points according to Apple's documentation.

Is there a use case for reporting the size in points to an app that has requested SDL_WINDOW_ALLOW_HIGHDPI. I can't see one.
Comment 2 Alex Szpakowski 2017-03-17 02:55:49 UTC
(In reply to Mark Callow from comment #0)
> When SDL_WINDOW_ALLOW_HIGHDPI is set, width and height in
> SDL_WINDOWEVENT_SIZE_CHANGED events and returned by SDL_GetWindowSize() are
> the scaled size of the window not the high DPI size of the window.

This is intentional. See the readme: https://hg.libsdl.org/SDL/file/e212b4d00d84/docs/README-ios.md#l61

(In reply to Mark Callow from comment #1)
> Is there a use case for reporting the size in points to an app that has requested SDL_WINDOW_ALLOW_HIGHDPI. I can't see one.

Yes. Apps should almost exclusively be using the point size and not the pixel size (except for render target sizes and explicitly *per-pixel* information/operations such as shader fragment coordinates).

This is what users of high-DPI apps will expect, because this is how they appear at a consistent size across devices with different DPI scale factors.
Comment 3 Mark Callow 2017-03-25 09:38:17 UTC
Thanks Alex.

I might be able to retrieve the pixel size from the Vulkan surface. I'll check. If not, I will have to add another API to return the pixel size of the Vulkan/Metal surface attached to an SDL_window and probably some field(s) in SDL_window to store the information.