From c744369552ff61f482c3615dc4c2495a77b7b125 Mon Sep 17 00:00:00 2001 From: Bruno Van de Velde Date: Sat, 5 Nov 2022 10:51:36 +0100 Subject: [PATCH] Use Per Monitor Aware instead of System Aware for DPI scaling on Windows --- src/SFML/Window/Win32/WindowImplWin32.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 68df74f2..8b6ba3b7 100755 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -92,8 +92,12 @@ namespace { // We only check for E_INVALIDARG because we would get // E_ACCESSDENIED if the DPI was already set previously - // and S_OK means the call was successful - if (SetProcessDpiAwarenessFunc(ProcessSystemDpiAware) == E_INVALIDARG) + // and S_OK means the call was successful. + // We intentionally don't use Per Monitor V2 which can be + // enabled with SetProcessDpiAwarenessContext, because that + // would scale the title bar and thus change window size + // by default when moving the window between monitors. + if (SetProcessDpiAwarenessFunc(ProcessPerMonitorDpiAware) == E_INVALIDARG) { sf::err() << "Failed to set process DPI awareness" << std::endl; }