aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfalkTX <falktx@falktx.com>2021-07-02 09:01:21 +0100
committerDavid Robillard <d@drobilla.net>2021-10-09 11:09:02 -0400
commitfbf5ed0b43dc28bf1118c42f417c7f498db9379d (patch)
treecfb7ab2349a580f56212e0fa997f887c87b43cd5
parente1569942291787743e86ab7445944dc4d451ef73 (diff)
downloadpugl-fbf5ed0b43dc28bf1118c42f417c7f498db9379d.tar.gz
pugl-fbf5ed0b43dc28bf1118c42f417c7f498db9379d.tar.bz2
pugl-fbf5ed0b43dc28bf1118c42f417c7f498db9379d.zip
Only call SetProcessDPIAware in programs
This prevents plugins from changing global host state, which causes serious problems in hosts that are not DPI aware.
-rw-r--r--src/win.c21
1 files 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;