From 9befda5c26d478b3acfd03acc74ea3426fbfc60c Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 10 Dec 2023 18:21:08 +0100 Subject: [PATCH] Only use AutoSystemDpiAware when displays have different DPI So the native win32 dialogs, like font and colour picker, are not shown blurry unnecessary. Fixes #24121 --- include/wx/msw/private/dpiaware.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/wx/msw/private/dpiaware.h b/include/wx/msw/private/dpiaware.h index 89165d00b4..122546df8a 100644 --- a/include/wx/msw/private/dpiaware.h +++ b/include/wx/msw/private/dpiaware.h @@ -15,6 +15,7 @@ #endif #include "wx/dynlib.h" +#include "wx/display.h" namespace wxMSWImpl { @@ -35,6 +36,9 @@ public: AutoSystemDpiAware() : m_prevContext(WXDPI_AWARENESS_CONTEXT_UNAWARE) { + if ( !Needed() ) + return; + if ( ms_pfnSetThreadDpiAwarenessContext == (SetThreadDpiAwarenessContext_t)-1) { wxLoadedDLL dllUser32("user32.dll"); @@ -62,6 +66,15 @@ public: } } + static bool Needed() + { + // use system-dpi-aware context when there are displays with different DPI + bool diferentDPI = false; + for ( unsigned i = 1; i < wxDisplay::GetCount() && !diferentDPI; ++i ) + diferentDPI = wxDisplay(0u).GetPPI() != wxDisplay(i).GetPPI(); + return diferentDPI; + } + private: WXDPI_AWARENESS_CONTEXT m_prevContext;