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 3709

Summary: Assertion failure in WIN_GetDisplayUsableBounds on highdpi display
Product: SDL Reporter: Eric Wasylishen <ewasylishen>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: HG 2.1   
Hardware: x86_64   
OS: Windows 10   

Description Eric Wasylishen 2017-07-21 23:21:06 UTC
1. have a monitor with scaling set in Windows display settings. I have 2880x1800 with 200% scaling.
2. run testgl2 with "--info all". You should get the SDL_assert(hmon != NULL); assertion failing in WIN_GetDisplayUsableBounds.

Unfortunately I think the code in SDL_windowsmodes.c is fundamentally broken wherever it attempts to convert coordinates in the DEVMODE struct (which are always in pixels, even under DPI virtualization) to virtual screen coordinates (what MonitorFromPoint takes).
I think the only correct fix is to get a HMONITOR by doing a EnumDisplayMonitors and looking for a monitor name matching the DEVMODE.dmDeviceName , but I'm not sure about this as the msdn docs don't seem to say how to get a HMONITOR from a DEVMODE.

Tested on SDL2 7cfe088fafba, Windows 10 1703, build 15063.447
Comment 1 Eric Wasylishen 2017-08-11 07:22:33 UTC
The patch I added in https://bugzilla.libsdl.org/show_bug.cgi?id=3714 fixes this.
Comment 2 Sam Lantinga 2017-08-11 17:19:45 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/0060bcf673e8