Skip to content

Commit

Permalink
Win32: Fix compatibility with Windows Server 2012, 2016, Windows 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox authored and HeikoKlare committed Oct 31, 2024
1 parent d54cfca commit c363394
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
40 changes: 40 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -3276,7 +3276,15 @@ 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;
}
Expand Down Expand Up @@ -3374,7 +3382,15 @@ 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;
}
Expand Down Expand Up @@ -6616,7 +6632,15 @@ JNIEXPORT jlong JNICALL OS_NATIVE(OpenThemeDataForDpi)
jlong rc = 0;
OS_NATIVE_ENTER(env, that, OpenThemeDataForDpi_FUNC);
if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
/*
rc = (jlong)OpenThemeDataForDpi((HWND)arg0, (LPCWSTR)lparg1, arg2);
*/
{
OS_LOAD_FUNCTION(fp, OpenThemeDataForDpi)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)(HWND, LPCWSTR, jint))fp)((HWND)arg0, (LPCWSTR)lparg1, arg2);
}
}
fail:
if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
OS_NATIVE_EXIT(env, that, OpenThemeDataForDpi_FUNC);
Expand Down Expand Up @@ -8865,7 +8889,15 @@ 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;
}
Expand Down Expand Up @@ -9215,7 +9247,15 @@ 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@
/* Libraries for dynamic loaded functions */
#define GetDpiForMonitor_LIB "shcore.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"
Original file line number Diff line number Diff line change
Expand Up @@ -2990,6 +2990,7 @@ 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);
Expand Down Expand Up @@ -3784,6 +3785,7 @@ public static int HRESULT_FROM_WIN32(int x) {
*/
public static final native long OpenThemeData (long hwnd, char[] pszClassList);
/**
* @method flags=dynamic
* @param hwnd cast=(HWND)
* @param pszClassList cast=(LPCWSTR),flags=no_out
*/
Expand Down Expand Up @@ -4354,8 +4356,12 @@ 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 ();
/** @param dpiContext cast=(DPI_AWARENESS_CONTEXT) */
/**
* @method flags=dynamic
* @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);
Expand Down Expand Up @@ -4462,6 +4468,7 @@ 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)
Expand Down

0 comments on commit c363394

Please sign in to comment.