Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Nemkin2018-04-25 07:20:15 +0000
committerNikita Nemkin2018-04-26 11:55:03 +0000
commitcdc67cbff3fb701108f19e6dbec01306872e31dc (patch)
tree8c182399913e9b521b75276a173b191ee82ba516 /bundles/org.eclipse.swt/Eclipse SWT PI
parent7283c66382291ec1d3eff3a3d435a713c1dd23e3 (diff)
downloadeclipse.platform.swt-cdc67cbff3fb701108f19e6dbec01306872e31dc.tar.gz
eclipse.platform.swt-cdc67cbff3fb701108f19e6dbec01306872e31dc.tar.xz
eclipse.platform.swt-cdc67cbff3fb701108f19e6dbec01306872e31dc.zip
Bug 480639 - Provide monitor-specific DPI scaling / zoom level
* Use flags=dynamic for GetDpiForMonitor * Set Monitor.zoom at Monitor creation time. Change-Id: I2756292bc673aa661b5cb0b97450a7677a730ae4 Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c104
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java43
5 files changed, 32 insertions, 128 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 cdf5c9dac6..6252d862d8 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
@@ -652,23 +652,6 @@ JNIEXPORT jint JNICALL OS_NATIVE(CRYPT_1OBJID_1BLOB_1sizeof)
}
#endif
-#ifndef NO_Call
-JNIEXPORT void JNICALL OS_NATIVE(Call)
- (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jintArray arg3, jintArray arg4)
-{
- jint *lparg3=NULL;
- jint *lparg4=NULL;
- OS_NATIVE_ENTER(env, that, Call_FUNC);
- if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
- if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
- ((void (*)())arg0)(arg1, arg2, lparg3, lparg4);
-fail:
- if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
- if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- OS_NATIVE_EXIT(env, that, Call_FUNC);
-}
-#endif
-
#ifndef NO_CallNextHookEx
JNIEXPORT jintLong JNICALL OS_NATIVE(CallNextHookEx)
(JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintLong arg2, jintLong arg3)
@@ -2867,18 +2850,6 @@ fail:
}
#endif
-#ifndef NO_FreeLibrary
-JNIEXPORT jboolean JNICALL OS_NATIVE(FreeLibrary)
- (JNIEnv *env, jclass that, jintLong arg0)
-{
- jboolean rc = 0;
- OS_NATIVE_ENTER(env, that, FreeLibrary_FUNC);
- rc = (jboolean)FreeLibrary((HMODULE)arg0);
- OS_NATIVE_EXIT(env, that, FreeLibrary_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_GCP_1RESULTS_1sizeof
JNIEXPORT jint JNICALL OS_NATIVE(GCP_1RESULTS_1sizeof)
(JNIEnv *env, jclass that)
@@ -3566,6 +3537,33 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetDoubleClickTime)
}
#endif
+#ifndef NO_GetDpiForMonitor
+JNIEXPORT jint JNICALL OS_NATIVE(GetDpiForMonitor)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintArray arg2, jintArray arg3)
+{
+ jint *lparg2=NULL;
+ jint *lparg3=NULL;
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, GetDpiForMonitor_FUNC);
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+/*
+ rc = (jint)GetDpiForMonitor(arg0, arg1, lparg2, lparg3);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, GetDpiForMonitor)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(jintLong, jint, jint *, jint *))fp)(arg0, arg1, lparg2, lparg3);
+ }
+ }
+fail:
+ if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ OS_NATIVE_EXIT(env, that, GetDpiForMonitor_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_GetFocus
JNIEXPORT jintLong JNICALL OS_NATIVE(GetFocus)
(JNIEnv *env, jclass that)
@@ -4553,22 +4551,6 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetPolyFillMode)
}
#endif
-#ifndef NO_GetProcAddress
-JNIEXPORT jintLong JNICALL OS_NATIVE(GetProcAddress)
- (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1)
-{
- jbyte *lparg1=NULL;
- jintLong rc = 0;
- OS_NATIVE_ENTER(env, that, GetProcAddress_FUNC);
- if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
- rc = (jintLong)GetProcAddress((HMODULE)arg0, (LPCTSTR)lparg1);
-fail:
- if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- OS_NATIVE_EXIT(env, that, GetProcAddress_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_GetProcessHeap
JNIEXPORT jintLong JNICALL OS_NATIVE(GetProcessHeap)
(JNIEnv *env, jclass that)
@@ -6765,38 +6747,6 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(LoadImageW)
}
#endif
-#ifndef NO_LoadLibraryA
-JNIEXPORT jintLong JNICALL OS_NATIVE(LoadLibraryA)
- (JNIEnv *env, jclass that, jbyteArray arg0)
-{
- jbyte *lparg0=NULL;
- jintLong rc = 0;
- OS_NATIVE_ENTER(env, that, LoadLibraryA_FUNC);
- if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
- rc = (jintLong)LoadLibraryA((LPSTR)lparg0);
-fail:
- if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- OS_NATIVE_EXIT(env, that, LoadLibraryA_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_LoadLibraryW
-JNIEXPORT jintLong JNICALL OS_NATIVE(LoadLibraryW)
- (JNIEnv *env, jclass that, jcharArray arg0)
-{
- jchar *lparg0=NULL;
- jintLong rc = 0;
- OS_NATIVE_ENTER(env, that, LoadLibraryW_FUNC);
- if (arg0) if ((lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL)) == NULL) goto fail;
- rc = (jintLong)LoadLibraryW((LPWSTR)lparg0);
-fail:
- if (arg0 && lparg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- OS_NATIVE_EXIT(env, that, LoadLibraryW_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_LocalFree
JNIEXPORT jintLong JNICALL OS_NATIVE(LocalFree)
(JNIEnv *env, jclass that, jintLong arg0)
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 529bb52995..cf8aa741e6 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
@@ -43,6 +43,7 @@
#define DwmExtendFrameIntoClientArea_LIB "dwmapi.dll"
#define DwmIsCompositionEnabled_LIB "dwmapi.dll"
#define GetCurrentProcessExplicitAppUserModelID_LIB "shell32.dll"
+#define GetDpiForMonitor_LIB "shcore.dll"
#define GetGestureInfo_LIB "user32.dll"
#define GetThemeInt_LIB "uxtheme.dll"
#define GetThemeMargins_LIB "uxtheme.dll"
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
index 535c93ce32..b462daa83c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
@@ -59,7 +59,6 @@ char * OS_nativeFunctionNames[] = {
"CRYPT_1BIT_1BLOB_1sizeof",
"CRYPT_1INTEGER_1BLOB_1sizeof",
"CRYPT_1OBJID_1BLOB_1sizeof",
- "Call",
"CallNextHookEx",
"CallWindowProcA",
"CallWindowProcW",
@@ -218,7 +217,6 @@ char * OS_nativeFunctionNames[] = {
"FillRect",
"FormatMessageA",
"FormatMessageW",
- "FreeLibrary",
"GCP_1RESULTS_1sizeof",
"GESTURECONFIG_1sizeof",
"GESTUREINFO_1sizeof",
@@ -267,6 +265,7 @@ char * OS_nativeFunctionNames[] = {
"GetDialogBaseUnits",
"GetDlgItem",
"GetDoubleClickTime",
+ "GetDpiForMonitor",
"GetFocus",
"GetFontLanguageInfo",
"GetForegroundWindow",
@@ -364,7 +363,6 @@ char * OS_nativeFunctionNames[] = {
"GetParent",
"GetPixel",
"GetPolyFillMode",
- "GetProcAddress",
"GetProcessHeap",
"GetProfileStringA",
"GetProfileStringW",
@@ -536,8 +534,6 @@ char * OS_nativeFunctionNames[] = {
"LoadIconW",
"LoadImageA",
"LoadImageW",
- "LoadLibraryA",
- "LoadLibraryW",
"LocalFree",
"MAKELPARAM",
"MAKELRESULT",
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 1e689e704a..bbff40fbb1 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
@@ -69,7 +69,6 @@ typedef enum {
CRYPT_1BIT_1BLOB_1sizeof_FUNC,
CRYPT_1INTEGER_1BLOB_1sizeof_FUNC,
CRYPT_1OBJID_1BLOB_1sizeof_FUNC,
- Call_FUNC,
CallNextHookEx_FUNC,
CallWindowProcA_FUNC,
CallWindowProcW_FUNC,
@@ -228,7 +227,6 @@ typedef enum {
FillRect_FUNC,
FormatMessageA_FUNC,
FormatMessageW_FUNC,
- FreeLibrary_FUNC,
GCP_1RESULTS_1sizeof_FUNC,
GESTURECONFIG_1sizeof_FUNC,
GESTUREINFO_1sizeof_FUNC,
@@ -277,6 +275,7 @@ typedef enum {
GetDialogBaseUnits_FUNC,
GetDlgItem_FUNC,
GetDoubleClickTime_FUNC,
+ GetDpiForMonitor_FUNC,
GetFocus_FUNC,
GetFontLanguageInfo_FUNC,
GetForegroundWindow_FUNC,
@@ -374,7 +373,6 @@ typedef enum {
GetParent_FUNC,
GetPixel_FUNC,
GetPolyFillMode_FUNC,
- GetProcAddress_FUNC,
GetProcessHeap_FUNC,
GetProfileStringA_FUNC,
GetProfileStringW_FUNC,
@@ -546,8 +544,6 @@ typedef enum {
LoadIconW_FUNC,
LoadImageA_FUNC,
LoadImageW_FUNC,
- LoadLibraryA_FUNC,
- LoadLibraryW_FUNC,
LocalFree_FUNC,
MAKELPARAM_FUNC,
MAKELRESULT_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 620a81f219..4298683ac1 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
@@ -2167,26 +2167,6 @@ public static final native int WINDOWPLACEMENT_sizeof ();
public static final native int WINDOWPOS_sizeof ();
public static final native int WNDCLASS_sizeof ();
-public static final int GetDpiForMonitor (long /*int*/ hmonitor, int dpiType, int [] dpiX, int [] dpiY) {
- TCHAR lpLibFileName = new TCHAR (0, "Shcore.dll", true); //$NON-NLS-1$
- long /*int*/ hModule = OS.LoadLibrary (lpLibFileName);
- if (hModule != 0) {
- String name = "GetDpiForMonitor\0"; //$NON-NLS-1$
- byte [] lpProcName = new byte [name.length ()];
- for (int i=0; i<lpProcName.length; i++) {
- lpProcName [i] = (byte) name.charAt (i);
- }
- long /*int*/ DllGetDpiForMonitor = OS.GetProcAddress (hModule, lpProcName);
- if (DllGetDpiForMonitor != 0) {
- dpiX [0] = dpiY [0] = -1;
- OS.Call (DllGetDpiForMonitor, hmonitor, dpiType, dpiX, dpiY);
- }
- OS.FreeLibrary (hModule);
- return dpiX [0] == -1 ? -1 : 0; // return result if API call succeeded
- }
- return -1;
-}
-
/** Ansi/Unicode wrappers */
public static final long /*int*/ AddFontResourceEx (TCHAR lpszFilename, int fl, long /*int*/ pdv) {
@@ -2700,15 +2680,6 @@ public static final long /*int*/ LoadImage (long /*int*/ hinst, long /*int*/ lps
return LoadImageA (hinst, lpszName, uType, cxDesired, cyDesired, fuLoad);
}
-public static final long /*int*/ LoadLibrary (TCHAR lpLibFileName) {
- if (IsUnicode) {
- char [] lpLibFileName1 = lpLibFileName == null ? null : lpLibFileName.chars;
- return LoadLibraryW (lpLibFileName1);
- }
- byte [] lpLibFileName1 = lpLibFileName == null ? null : lpLibFileName.bytes;
- return LoadLibraryA (lpLibFileName1);
-}
-
public static final int MapVirtualKey (int uCode, int uMapType) {
if (IsUnicode) return MapVirtualKeyW (uCode, uMapType);
return MapVirtualKeyA (uCode, uMapType);
@@ -3283,7 +3254,6 @@ public static final native boolean BringWindowToTop (long /*int*/ hWnd);
public static final native int BufferedPaintInit ();
/** @method flags=dynamic */
public static final native int BufferedPaintUnInit ();
-public static native void Call (long /*int*/ address, long /*int*/ hmonitor, int dpiType, int[] dpiX, int[] dpiY);
/**
* @param hhk cast=(HHOOK)
* @param wParam cast=(WPARAM)
@@ -3774,8 +3744,6 @@ public static final native int FormatMessageA (int dwFlags, long /*int*/ lpSourc
* @param Arguments cast=(va_list*)
*/
public static final native int FormatMessageW (int dwFlags, long /*int*/ lpSource, int dwMessageId, int dwLanguageId, long /*int*/ [] lpBuffer, int nSize, long /*int*/ Arguments);
-/** @param hLibModule cast=(HMODULE) */
-public static final native boolean FreeLibrary (long /*int*/ hLibModule);
/** @param dwLimit cast=(DWORD) */
public static final native int GdiSetBatchLimit (int dwLimit);
public static final native int GET_WHEEL_DELTA_WPARAM(long /*int*/ wParam);
@@ -3885,6 +3853,8 @@ public static final native int GetDIBits (long /*int*/ hdc, long /*int*/ hbmp, i
/** @param hDlg cast=(HWND) */
public static final native long /*int*/ GetDlgItem (long /*int*/ hDlg, int nIDDlgItem);
public static final native int GetDoubleClickTime ();
+/** @method flags=dynamic */
+public static final native int GetDpiForMonitor (long /*int*/ hmonitor, int dpiType, int [] dpiX, int [] dpiY);
public static final native long /*int*/ GetFocus ();
/** @param hdc cast=(HDC) */
public static final native int GetFontLanguageInfo (long /*int*/ hdc);
@@ -4087,11 +4057,6 @@ public static final native boolean OpenPrinterW (char[] pPrinterName, long /*int
* @param pDefault cast=(LPPRINTER_DEFAULTS)
*/
public static final native boolean OpenPrinterA (byte[] pPrinterName, long /*int*/ [] phPrinter, long /*int*/ pDefault);
-/**
- * @param hModule cast=(HMODULE)
- * @param lpProcName cast=(LPCTSTR)
- */
-public static final native long /*int*/ GetProcAddress (long /*int*/ hModule, byte [] lpProcName);
public static final native long /*int*/ GetProcessHeap ();
/**
* @param lpAppName cast=(LPWSTR)
@@ -4532,10 +4497,6 @@ public static final native long /*int*/ LoadImageW (long /*int*/ hinst, long /*i
* @param lpszName cast=(LPSTR)
*/
public static final native long /*int*/ LoadImageA (long /*int*/ hinst, long /*int*/ lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
-/** @param lpLibFileName cast=(LPWSTR) */
-public static final native long /*int*/ LoadLibraryW (char [] lpLibFileName);
-/** @param lpLibFileName cast=(LPSTR) */
-public static final native long /*int*/ LoadLibraryA (byte [] lpLibFileName);
/** @param hMem cast=(HLOCAL) */
public static final native long /*int*/ LocalFree (long /*int*/ hMem);
public static final native int LODWORD (long l);

Back to the top