Skip to content

Commit c363394

Browse files
ShadelessFoxHeikoKlare
authored andcommitted
Win32: Fix compatibility with Windows Server 2012, 2016, Windows 8.1
1 parent d54cfca commit c363394

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3276,7 +3276,15 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetSystemMetricsForDpi)
32763276
{
32773277
jint rc = 0;
32783278
OS_NATIVE_ENTER(env, that, GetSystemMetricsForDpi_FUNC);
3279+
/*
32793280
rc = (jint)GetSystemMetricsForDpi(arg0, arg1);
3281+
*/
3282+
{
3283+
OS_LOAD_FUNCTION(fp, GetSystemMetricsForDpi)
3284+
if (fp) {
3285+
rc = (jint)((jint (CALLING_CONVENTION*)(jint, jint))fp)(arg0, arg1);
3286+
}
3287+
}
32803288
OS_NATIVE_EXIT(env, that, GetSystemMetricsForDpi_FUNC);
32813289
return rc;
32823290
}
@@ -3374,7 +3382,15 @@ JNIEXPORT jlong JNICALL OS_NATIVE(GetThreadDpiAwarenessContext)
33743382
{
33753383
jlong rc = 0;
33763384
OS_NATIVE_ENTER(env, that, GetThreadDpiAwarenessContext_FUNC);
3385+
/*
33773386
rc = (jlong)GetThreadDpiAwarenessContext();
3387+
*/
3388+
{
3389+
OS_LOAD_FUNCTION(fp, GetThreadDpiAwarenessContext)
3390+
if (fp) {
3391+
rc = (jlong)((jlong (CALLING_CONVENTION*)())fp)();
3392+
}
3393+
}
33783394
OS_NATIVE_EXIT(env, that, GetThreadDpiAwarenessContext_FUNC);
33793395
return rc;
33803396
}
@@ -6616,7 +6632,15 @@ JNIEXPORT jlong JNICALL OS_NATIVE(OpenThemeDataForDpi)
66166632
jlong rc = 0;
66176633
OS_NATIVE_ENTER(env, that, OpenThemeDataForDpi_FUNC);
66186634
if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
6635+
/*
66196636
rc = (jlong)OpenThemeDataForDpi((HWND)arg0, (LPCWSTR)lparg1, arg2);
6637+
*/
6638+
{
6639+
OS_LOAD_FUNCTION(fp, OpenThemeDataForDpi)
6640+
if (fp) {
6641+
rc = (jlong)((jlong (CALLING_CONVENTION*)(HWND, LPCWSTR, jint))fp)((HWND)arg0, (LPCWSTR)lparg1, arg2);
6642+
}
6643+
}
66206644
fail:
66216645
if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
66226646
OS_NATIVE_EXIT(env, that, OpenThemeDataForDpi_FUNC);
@@ -8865,7 +8889,15 @@ JNIEXPORT jlong JNICALL OS_NATIVE(SetThreadDpiAwarenessContext)
88658889
{
88668890
jlong rc = 0;
88678891
OS_NATIVE_ENTER(env, that, SetThreadDpiAwarenessContext_FUNC);
8892+
/*
88688893
rc = (jlong)SetThreadDpiAwarenessContext((DPI_AWARENESS_CONTEXT)arg0);
8894+
*/
8895+
{
8896+
OS_LOAD_FUNCTION(fp, SetThreadDpiAwarenessContext)
8897+
if (fp) {
8898+
rc = (jlong)((jlong (CALLING_CONVENTION*)(DPI_AWARENESS_CONTEXT))fp)((DPI_AWARENESS_CONTEXT)arg0);
8899+
}
8900+
}
88698901
OS_NATIVE_EXIT(env, that, SetThreadDpiAwarenessContext_FUNC);
88708902
return rc;
88718903
}
@@ -9215,7 +9247,15 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoForDpi)
92159247
jboolean rc = 0;
92169248
OS_NATIVE_ENTER(env, that, SystemParametersInfoForDpi_FUNC);
92179249
if (arg2) if ((lparg2 = getNONCLIENTMETRICSFields(env, arg2, &_arg2)) == NULL) goto fail;
9250+
/*
92189251
rc = (jboolean)SystemParametersInfoForDpi(arg0, arg1, lparg2, arg3, arg4);
9252+
*/
9253+
{
9254+
OS_LOAD_FUNCTION(fp, SystemParametersInfoForDpi)
9255+
if (fp) {
9256+
rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jint, jint, NONCLIENTMETRICS *, jint, jint))fp)(arg0, arg1, lparg2, arg3, arg4);
9257+
}
9258+
}
92199259
fail:
92209260
if (arg2 && lparg2) setNONCLIENTMETRICSFields(env, arg2, lparg2);
92219261
OS_NATIVE_EXIT(env, that, SystemParametersInfoForDpi_FUNC);

bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@
2020
/* Libraries for dynamic loaded functions */
2121
#define GetDpiForMonitor_LIB "shcore.dll"
2222
#define RtlGetVersion_LIB "ntdll.dll"
23+
#define OpenThemeDataForDpi_LIB "uxtheme.dll"
24+
#define GetSystemMetricsForDpi_LIB "user32.dll"
25+
#define GetThreadDpiAwarenessContext_LIB "user32.dll"
26+
#define SetThreadDpiAwarenessContext_LIB "user32.dll"
27+
#define SystemParametersInfoForDpi_LIB "user32.dll"

bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2990,6 +2990,7 @@ public static int HRESULT_FROM_WIN32(int x) {
29902990
/** @param hWnd cast=(HWND) */
29912991
public static final native long GetSystemMenu (long hWnd, boolean bRevert);
29922992
public static final native int GetSystemMetrics (int nIndex);
2993+
/** @method flags=dynamic */
29932994
public static final native int GetSystemMetricsForDpi (int nIndex, int dpi);
29942995
/** @param hDC cast=(HDC) */
29952996
public static final native int GetTextColor (long hDC);
@@ -3784,6 +3785,7 @@ public static int HRESULT_FROM_WIN32(int x) {
37843785
*/
37853786
public static final native long OpenThemeData (long hwnd, char[] pszClassList);
37863787
/**
3788+
* @method flags=dynamic
37873789
* @param hwnd cast=(HWND)
37883790
* @param pszClassList cast=(LPCWSTR),flags=no_out
37893791
*/
@@ -4354,8 +4356,12 @@ public static int HRESULT_FROM_WIN32(int x) {
43544356
/** @param hdc cast=(HDC) */
43554357
public static final native int SetPolyFillMode (long hdc, int iPolyFillMode);
43564358
public static final native boolean SetProcessDPIAware ();
4357-
/** @param dpiContext cast=(DPI_AWARENESS_CONTEXT) */
4359+
/**
4360+
* @method flags=dynamic
4361+
* @param dpiContext cast=(DPI_AWARENESS_CONTEXT)
4362+
*/
43584363
public static final native long SetThreadDpiAwarenessContext (long dpiContext);
4364+
/** @method flags=dynamic */
43594365
public static final native long GetThreadDpiAwarenessContext ();
43604366
/** @method flags=no_gen */
43614367
public static final native int SetPreferredAppMode(int mode);
@@ -4462,6 +4468,7 @@ public static int HRESULT_FROM_WIN32(int x) {
44624468
public static final native boolean SystemParametersInfo (int uiAction, int uiParam, RECT pvParam, int fWinIni);
44634469
public static final native boolean SystemParametersInfo (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni);
44644470
public static final native boolean SystemParametersInfo (int uiAction, int uiParam, int [] pvParam, int fWinIni);
4471+
/** @method flags=dynamic */
44654472
public static final native boolean SystemParametersInfoForDpi (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni, int dpi);
44664473
/**
44674474
* @param lpKeyState cast=(PBYTE)

0 commit comments

Comments
 (0)