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
This commit is contained in:
Maarten Bent 2023-12-10 18:21:08 +01:00
parent a2f7a933e8
commit 9befda5c26
No known key found for this signature in database
GPG key ID: 58AAEE3F4A4FD070

View file

@ -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;