From 23d3655e9754857bc646dc7e3d1fdf5090d9665b Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Thu, 4 Jun 2026 11:43:39 +0200 Subject: [PATCH] [Win32] Remove runtime change of process DPI awareness SWT initialization modifies the process DPI awareness via the static initializer of the OS class. This has been implemented for DPI awareness on Windows Vista long time ago. Changing process DPI awareness programmatically is discouraged and should rather be done by the application's manifest. In addition, relevant executables into which SWT is embedded (JVM, Equinox launcher etc.) already have state-of-the-art settings for DPI awareness, which even activate higher levels of DPI awareness than what the call to setProcessDPIAware (conforming to "System" DPI awareness) does. In consequence, this call has no benefit but may rather interfere with DPI awareness settings already done via the manifest. This change thus removes the obsolete programmatic setting of process DPI awareness along with the now unused native method. --- .../Eclipse SWT PI/win32/library/os.c | 12 ------------ .../Eclipse SWT PI/win32/library/os_stats.h | 1 - .../win32/org/eclipse/swt/internal/win32/OS.java | 4 ---- 3 files changed, 17 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c index 0f8d6efc34f..af6ce424220 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c @@ -8811,18 +8811,6 @@ JNIEXPORT jint JNICALL OS_NATIVE(SetPolyFillMode) } #endif -#ifndef NO_SetProcessDPIAware -JNIEXPORT jboolean JNICALL OS_NATIVE(SetProcessDPIAware) - (JNIEnv *env, jclass that) -{ - jboolean rc = 0; - OS_NATIVE_ENTER(env, that, SetProcessDPIAware_FUNC); - rc = (jboolean)SetProcessDPIAware(); - OS_NATIVE_EXIT(env, that, SetProcessDPIAware_FUNC); - return rc; -} -#endif - #ifndef NO_SetProp JNIEXPORT jboolean JNICALL OS_NATIVE(SetProp) (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h index b9e62062010..5c0a094fd6b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h @@ -657,7 +657,6 @@ typedef enum { SetPixel_FUNC, SetPolyFillMode_FUNC, SetPreferredAppMode_FUNC, - SetProcessDPIAware_FUNC, SetProp_FUNC, SetROP2_FUNC, SetRect_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index debdd67e2f0..be4b31c7c1b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -59,9 +59,6 @@ public class OS extends C { */ } - /* Make the process DPI aware for Windows Vista */ - OS.SetProcessDPIAware (); - /* Get the DBCS flag */ IsDBLocale = OS.GetSystemMetrics (SM_IMMENABLED) != 0; } @@ -4369,7 +4366,6 @@ public static int HRESULT_FROM_WIN32(int x) { public static final native int SetPixel (long hdc, int X, int Y, int crColor); /** @param hdc cast=(HDC) */ public static final native int SetPolyFillMode (long hdc, int iPolyFillMode); -public static final native boolean SetProcessDPIAware (); /** * @method flags=dynamic * @param dpiContext cast=(DPI_AWARENESS_CONTEXT)