From fbf5ed0b43dc28bf1118c42f417c7f498db9379d Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 2 Jul 2021 09:01:21 +0100 Subject: Only call SetProcessDPIAware in programs This prevents plugins from changing global host state, which causes serious problems in hosts that are not DPI aware. --- src/win.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/win.c b/src/win.c index dc1e62c..32232c0 100644 --- a/src/win.c +++ b/src/win.c @@ -118,8 +118,7 @@ puglWinGetWindowExFlags(const PuglView* const view) } PuglWorldInternals* -puglInitWorldInternals(PuglWorldType PUGL_UNUSED(type), - PuglWorldFlags PUGL_UNUSED(flags)) +puglInitWorldInternals(PuglWorldType type, PuglWorldFlags PUGL_UNUSED(flags)) { PuglWorldInternals* impl = (PuglWorldInternals*)calloc(1, sizeof(PuglWorldInternals)); @@ -127,15 +126,17 @@ puglInitWorldInternals(PuglWorldType PUGL_UNUSED(type), return NULL; } - HMODULE user32 = LoadLibrary("user32.dll"); - if (user32) { - PFN_SetProcessDPIAware SetProcessDPIAware = - (PFN_SetProcessDPIAware)GetProcAddress(user32, "SetProcessDPIAware"); - if (SetProcessDPIAware) { - SetProcessDPIAware(); - } + if (type == PUGL_PROGRAM) { + HMODULE user32 = LoadLibrary("user32.dll"); + if (user32) { + PFN_SetProcessDPIAware SetProcessDPIAware = + (PFN_SetProcessDPIAware)GetProcAddress(user32, "SetProcessDPIAware"); + if (SetProcessDPIAware) { + SetProcessDPIAware(); + } - FreeLibrary(user32); + FreeLibrary(user32); + } } LARGE_INTEGER frequency; -- cgit v1.2.1