0

I have a DPI Aware application(via manifest file) and on 1 monitor system all the the following methods are returning wrong desktop resolution:

  • GetSystemMetrics
  • GetMonitorInfo
  • GetWindowRect(GetDesktopWindow(), &desktop)
  • EnumDisplaySettingsExA/ENUM_CURRENT_SETTINGS
  • IDXGIOutput::GetDesc

My monitor is 4k but I set desktop size to 1920x1080 with 100% scale. When in windowed mode the reported resolution via all the methods is correct. However when switched to full-screen they all return 1600x1200. If it was DPI Aware problem it should at least keep the aspect ratio, e.g. 1600x900.

I noticed that the wrong results are after a call to IDXGISwapChain::SetFullscreenState(true, output_device) where the swap chain object is created with the flag DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH as per MSDN.

The app is using DirectX 11.

Any suggestions what my cause this?

Thank you

xenomeno
  • 63
  • 7
  • Are you 100% sure your full-screen resolution matches the desktop resolution? This is in general not the case... – rubenvb Mar 08 '19 at 12:30
  • 1
    Pretty safe to assume this has nothing to do with dpi-awareness. There is a [dedicated doc page](https://learn.microsoft.com/en-us/windows/desktop/direct3darticles/dxgi-best-practices#full-screen-issues) about full-screen issues, quoting: "Many applications, however, switch to a preferred full-screen resolution." – Hans Passant Mar 08 '19 at 13:08
  • @rubenvb yes, the full-screen resolution was a little bit off(due to going from Exclusive-Windowed-Exclusive) leading to not properly resizing the DX targets which should be called before SetFullscreenState(). – xenomeno Mar 08 '19 at 14:55

1 Answers1

1

So I found the issue - the IDXGISwapChain::ResizeTarget(mode) which need to be resized before going to fullscreen was with wrong resolution(due to previous windowed mode with custom size). This caused IDXGISwapChain::SetFullscreenState(true, output_device)to switch to different strange desktop resolutions depending on what happened to be the size of the DX targets. Setting the targets with the proper desktop resolution(taken via EnumDisplaySettingsExA/ENUM_CURRENT_SETTINGS) before changing the state solved it.

xenomeno
  • 63
  • 7