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 ceb19ea77eb..1ddb3138a19 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 @@ -132,15 +132,7 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(AdjustWindowRectExForDpi) jboolean rc = 0; OS_NATIVE_ENTER(env, that, AdjustWindowRectExForDpi_FUNC); if (arg0) if ((lparg0 = getRECTFields(env, arg0, &_arg0)) == NULL) goto fail; -/* rc = (jboolean)AdjustWindowRectExForDpi(lparg0, arg1, arg2, arg3, arg4); -*/ - { - OS_LOAD_FUNCTION(fp, AdjustWindowRectExForDpi) - if (fp) { - rc = (jboolean)((jboolean (CALLING_CONVENTION*)(RECT *, jint, jboolean, jint, jint))fp)(lparg0, arg1, arg2, arg3, arg4); - } - } fail: if (arg0 && lparg0) setRECTFields(env, arg0, lparg0); OS_NATIVE_EXIT(env, that, AdjustWindowRectExForDpi_FUNC); @@ -2516,15 +2508,7 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetDpiForWindow) { jint rc = 0; OS_NATIVE_ENTER(env, that, GetDpiForWindow_FUNC); -/* - rc = (jint)GetDpiForWindow(arg0); -*/ - { - OS_LOAD_FUNCTION(fp, GetDpiForWindow) - if (fp) { - rc = (jint)((jint (CALLING_CONVENTION*)(jlong))fp)(arg0); - } - } + rc = (jint)GetDpiForWindow((HWND)arg0); OS_NATIVE_EXIT(env, that, GetDpiForWindow_FUNC); return rc; } @@ -3320,15 +3304,7 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetSystemMetricsForDpi) { jint rc = 0; OS_NATIVE_ENTER(env, that, GetSystemMetricsForDpi_FUNC); -/* rc = (jint)GetSystemMetricsForDpi(arg0, arg1); -*/ - { - OS_LOAD_FUNCTION(fp, GetSystemMetricsForDpi) - if (fp) { - rc = (jint)((jint (CALLING_CONVENTION*)(jint, jint))fp)(arg0, arg1); - } - } OS_NATIVE_EXIT(env, that, GetSystemMetricsForDpi_FUNC); return rc; } @@ -3426,15 +3402,7 @@ JNIEXPORT jlong JNICALL OS_NATIVE(GetThreadDpiAwarenessContext) { jlong rc = 0; OS_NATIVE_ENTER(env, that, GetThreadDpiAwarenessContext_FUNC); -/* rc = (jlong)GetThreadDpiAwarenessContext(); -*/ - { - OS_LOAD_FUNCTION(fp, GetThreadDpiAwarenessContext) - if (fp) { - rc = (jlong)((jlong (CALLING_CONVENTION*)())fp)(); - } - } OS_NATIVE_EXIT(env, that, GetThreadDpiAwarenessContext_FUNC); return rc; } @@ -8971,15 +8939,7 @@ JNIEXPORT jlong JNICALL OS_NATIVE(SetThreadDpiAwarenessContext) { jlong rc = 0; OS_NATIVE_ENTER(env, that, SetThreadDpiAwarenessContext_FUNC); -/* rc = (jlong)SetThreadDpiAwarenessContext((DPI_AWARENESS_CONTEXT)arg0); -*/ - { - OS_LOAD_FUNCTION(fp, SetThreadDpiAwarenessContext) - if (fp) { - rc = (jlong)((jlong (CALLING_CONVENTION*)(DPI_AWARENESS_CONTEXT))fp)((DPI_AWARENESS_CONTEXT)arg0); - } - } OS_NATIVE_EXIT(env, that, SetThreadDpiAwarenessContext_FUNC); return rc; } @@ -9329,15 +9289,7 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoForDpi) jboolean rc = 0; OS_NATIVE_ENTER(env, that, SystemParametersInfoForDpi_FUNC); if (arg2) if ((lparg2 = getNONCLIENTMETRICSFields(env, arg2, &_arg2)) == NULL) goto fail; -/* rc = (jboolean)SystemParametersInfoForDpi(arg0, arg1, lparg2, arg3, arg4); -*/ - { - OS_LOAD_FUNCTION(fp, SystemParametersInfoForDpi) - if (fp) { - rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jint, jint, NONCLIENTMETRICS *, jint, jint))fp)(arg0, arg1, lparg2, arg3, arg4); - } - } fail: if (arg2 && lparg2) setNONCLIENTMETRICSFields(env, arg2, lparg2); OS_NATIVE_EXIT(env, that, SystemParametersInfoForDpi_FUNC); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h index f26e394844f..131d6614f26 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h @@ -19,11 +19,5 @@ /* Libraries for dynamic loaded functions */ #define GetDpiForMonitor_LIB "shcore.dll" -#define GetDpiForWindow_LIB "user32.dll" #define RtlGetVersion_LIB "ntdll.dll" #define OpenThemeDataForDpi_LIB "uxtheme.dll" -#define GetSystemMetricsForDpi_LIB "user32.dll" -#define GetThreadDpiAwarenessContext_LIB "user32.dll" -#define SetThreadDpiAwarenessContext_LIB "user32.dll" -#define SystemParametersInfoForDpi_LIB "user32.dll" -#define AdjustWindowRectExForDpi_LIB "user32.dll" 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 267573ed8a2..f7698cf14c5 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 @@ -39,11 +39,11 @@ public class OS extends C { /** * Values taken from https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions */ - public static final int WIN32_BUILD_WIN8_1 = 9600; // "Windows 8.1" public static final int WIN32_BUILD_WIN10_1607 = 14393; // "Windows 10 August 2016 Update" public static final int WIN32_BUILD_WIN10_1809 = 17763; // "Windows 10 October 2018 Update" public static final int WIN32_BUILD_WIN10_2004 = 19041; // "Windows 10 May 2020 Update" public static final int WIN32_BUILD_WIN11_21H2 = 22000; // Initial Windows 11 release + public static final int MINIMUM_COMPATIBLE_OS_VERSION = WIN32_BUILD_WIN10_1607; public static final String NO_MANIFEST = "org.eclipse.swt.internal.win32.OS.NO_MANIFEST"; @@ -69,6 +69,8 @@ public class OS extends C { WIN32_BUILD = 0; } + checkCompatibleWindowsVersion(WIN32_BUILD); + /* Load the manifest to force the XP Theme */ if (System.getProperty (NO_MANIFEST) == null) { ACTCTX pActCtx = new ACTCTX (); @@ -93,6 +95,14 @@ public class OS extends C { IsDBLocale = OS.GetSystemMetrics (SM_IMMENABLED) != 0; } + private static void checkCompatibleWindowsVersion(int current) { + if (OS.WIN32_BUILD < OS.MINIMUM_COMPATIBLE_OS_VERSION) { + System.err.println(String.format("Incompatible OS: Minimum Windows build version is %s but current is %s", + OS.MINIMUM_COMPATIBLE_OS_VERSION, current)); + System.exit(0); + } + } + /* Constants */ public static final int ABS_DOWNDISABLED = 8; public static final int ABS_DOWNHOT = 6; @@ -2354,7 +2364,6 @@ public static int HRESULT_FROM_WIN32(int x) { */ public static final native int AddFontResourceEx(char[] lpszFilename, int fl, long pdv); public static final native boolean AdjustWindowRectEx (RECT lpRect, int dwStyle, boolean bMenu, int dwExStyle); -/** @method flags=dynamic */ public static final native boolean AdjustWindowRectExForDpi (RECT lpRect, int dwStyle, boolean bMenu, int dwExStyle, int dpi); /** @method flags=no_gen */ public static final native boolean AllowDarkModeForWindow(long hWnd, boolean allow); @@ -2820,7 +2829,7 @@ public static int HRESULT_FROM_WIN32(int x) { public static final native int GetDoubleClickTime (); /** @method flags=dynamic */ public static final native int GetDpiForMonitor (long hmonitor, int dpiType, int [] dpiX, int [] dpiY); -/** @method flags=dynamic */ +/** @param hWnd cast=(HWND) */ public static final native int GetDpiForWindow (long hWnd); public static final native long GetFocus (); /** @param hdc cast=(HDC) */ @@ -3006,7 +3015,6 @@ public static int HRESULT_FROM_WIN32(int x) { /** @param hWnd cast=(HWND) */ public static final native long GetSystemMenu (long hWnd, boolean bRevert); public static final native int GetSystemMetrics (int nIndex); -/** @method flags=dynamic */ public static final native int GetSystemMetricsForDpi (int nIndex, int dpi); /** @param hDC cast=(HDC) */ public static final native int GetTextColor (long hDC); @@ -4378,12 +4386,8 @@ public static int HRESULT_FROM_WIN32(int x) { /** @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) - */ +/** @param dpiContext cast=(DPI_AWARENESS_CONTEXT) */ public static final native long SetThreadDpiAwarenessContext (long dpiContext); -/** @method flags=dynamic */ public static final native long GetThreadDpiAwarenessContext (); /** @method flags=no_gen */ public static final native int SetPreferredAppMode(int mode); @@ -4496,7 +4500,6 @@ public static int HRESULT_FROM_WIN32(int x) { public static final native boolean SystemParametersInfo (int uiAction, int uiParam, RECT pvParam, int fWinIni); public static final native boolean SystemParametersInfo (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni); public static final native boolean SystemParametersInfo (int uiAction, int uiParam, int [] pvParam, int fWinIni); -/** @method flags=dynamic */ public static final native boolean SystemParametersInfoForDpi (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni, int dpi); /** * @param lpKeyState cast=(PBYTE) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java index 435a7ddb934..665d1008db5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java @@ -96,12 +96,8 @@ private long createSystemFontHandle(int zoom) { } private static boolean fetchSystemParametersInfo(NONCLIENTMETRICS info, int targetZoom) { - if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1607) { - return OS.SystemParametersInfoForDpi(OS.SPI_GETNONCLIENTMETRICS, NONCLIENTMETRICS.sizeof, info, 0, - DPIUtil.mapZoomToDPI(targetZoom)); - } else { - return OS.SystemParametersInfo(OS.SPI_GETNONCLIENTMETRICS, 0, info, 0); - } + return OS.SystemParametersInfoForDpi(OS.SPI_GETNONCLIENTMETRICS, NONCLIENTMETRICS.sizeof, info, 0, + DPIUtil.mapZoomToDPI(targetZoom)); } @Override diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index 8ba482a4713..15b1a744ec4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -2224,14 +2224,11 @@ public boolean print (GC gc) { } int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; OS.RedrawWindow (topHandle, null, 0, flags); - int printWindowFlags = 0; - if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN8_1) { - /* - * Undocumented flag in windows, which also allows the capturing - * of GPU-drawn areas, e.g. an embedded Edge WebView2. - */ - printWindowFlags |= OS.PW_RENDERFULLCONTENT; - } + /* + * Undocumented flag in windows, which also allows the capturing + * of GPU-drawn areas, e.g. an embedded Edge WebView2. + */ + int printWindowFlags = OS.PW_RENDERFULLCONTENT; printWidget (topHandle, hdc, gc, printWindowFlags); if (gdipGraphics != 0) { OS.RestoreDC(hdc, state); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index 5d2c82aadc4..38775af168e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -533,11 +533,7 @@ public class Display extends Device implements Executor { private static int ICON_SIZE_AT_100 = retrieveDefaultIconSize(); private static int retrieveDefaultIconSize() { - if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1607) { - return OS.GetSystemMetricsForDpi(OS.SM_CXICON, DPIUtil.mapZoomToDPI(100)); - } else { - return 32; - } + return OS.GetSystemMetricsForDpi(OS.SM_CXICON, DPIUtil.mapZoomToDPI(100)); } /* Skinning support */ @@ -5396,10 +5392,6 @@ private boolean setMonitorSpecificScaling(boolean activate) { } private boolean setDPIAwareness(int desiredDpiAwareness) { - if (OS.WIN32_BUILD < OS.WIN32_BUILD_WIN10_1607) { - System.err.println("***WARNING: the OS version does not support setting DPI awareness."); - return false; - } if (desiredDpiAwareness == OS.GetThreadDpiAwarenessContext()) { return true; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java index 490c84087d7..12f3efd2959 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java @@ -2699,23 +2699,11 @@ private static void handleDPIChange(Widget widget, int newZoom, float scalingFac } int getSystemMetrics(int nIndex) { - /* - * DPI dependent metrics were introduced after 2016 version of windows 10 - */ - if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1607) { - return OS.GetSystemMetricsForDpi(nIndex, DPIUtil.mapZoomToDPI(nativeZoom)); - } - return OS.GetSystemMetrics(nIndex); + return OS.GetSystemMetricsForDpi(nIndex, DPIUtil.mapZoomToDPI(nativeZoom)); } boolean adjustWindowRectEx(RECT lpRect, int dwStyle, boolean bMenu, int dwExStyle) { - /* - * DPI-dependent version of the method was introduced with Windows 10 Version 1607 - */ - if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1607) { - return OS.AdjustWindowRectExForDpi (lpRect, dwStyle, bMenu, dwExStyle, DPIUtil.mapZoomToDPI(nativeZoom)); - } - return OS.AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle); + return OS.AdjustWindowRectExForDpi (lpRect, dwStyle, bMenu, dwExStyle, DPIUtil.mapZoomToDPI(nativeZoom)); }