From 0ce906306b955cab497b67e8cee545d89359b432 Mon Sep 17 00:00:00 2001 From: Andreas Koch Date: Thu, 20 Feb 2025 12:50:27 +0100 Subject: [PATCH] [win32] add GetDpiForWindow OS call This commit adds the OS call for GetDpiForWindow. --- .../Eclipse SWT PI/win32/library/os.c | 20 +++++++++++++++++++ .../Eclipse SWT PI/win32/library/os_custom.h | 1 + .../Eclipse SWT PI/win32/library/os_stats.h | 1 + .../org/eclipse/swt/internal/win32/OS.java | 2 ++ 4 files changed, 24 insertions(+) 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 5777dd413e3..9b5a61b908c 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 @@ -2510,6 +2510,26 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetDpiForMonitor) } #endif +#ifndef NO_GetDpiForWindow +JNIEXPORT jint JNICALL OS_NATIVE(GetDpiForWindow) + (JNIEnv *env, jclass that, jlong arg0) +{ + 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); + } + } + OS_NATIVE_EXIT(env, that, GetDpiForWindow_FUNC); + return rc; +} +#endif + #ifndef NO_GetFocus JNIEXPORT jlong JNICALL OS_NATIVE(GetFocus) (JNIEnv *env, jclass that) 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 5230ab388da..f26e394844f 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,6 +19,7 @@ /* 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" 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 ddc3afef2ef..b828c865599 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 @@ -203,6 +203,7 @@ typedef enum { GetDlgItem_FUNC, GetDoubleClickTime_FUNC, GetDpiForMonitor_FUNC, + GetDpiForWindow_FUNC, GetFocus_FUNC, GetFontLanguageInfo_FUNC, GetForegroundWindow_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 9e3d32df788..c41bbfad527 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 @@ -2814,6 +2814,8 @@ 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 */ +public static final native int GetDpiForWindow (long hWnd); public static final native long GetFocus (); /** @param hdc cast=(HDC) */ public static final native int GetFontLanguageInfo (long hdc);