Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2018-04-06 07:39:30 +0000
committerLakshmi Shanmugam2018-04-10 17:05:51 +0000
commit13e0a92eb06604985b73e89050f2814cadcbf876 (patch)
tree4b5629b525dbec85c437ecf9e5d2b9cbb7384b06 /bundles/org.eclipse.swt/Eclipse SWT PI/win32/org
parent1ef04fc233c30990e4fcfd616b06c8ff1ae9936c (diff)
downloadeclipse.platform.swt-13e0a92eb06604985b73e89050f2814cadcbf876.tar.gz
eclipse.platform.swt-13e0a92eb06604985b73e89050f2814cadcbf876.tar.xz
eclipse.platform.swt-13e0a92eb06604985b73e89050f2814cadcbf876.zip
Bug 480639: Provide monitor-specific DPI scaling / zoom level
Added API Monitor.getZoom() to get zoom on Mac & Windows Change-Id: Ib1990d0cbb2190323f7204dd14c6674d99278efd Signed-off-by: Lakshmi Shanmugam <lshanmug@in.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI/win32/org')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java42
1 files changed, 42 insertions, 0 deletions
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 0f6fd03e7b..620a81f219 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
@@ -958,6 +958,7 @@ public class OS extends C {
public static final int MCN_SELECT = MCN_FIRST + 4;
public static final int MCS_NOTODAY = 0x0010;
public static final int MDIS_ALLCHILDSTYLES = 0x0001;
+ public static final int MDT_EFFECTIVE_DPI = 0;
public static final int MFS_CHECKED = 0x8;
public static final int MFS_DISABLED = 0x3;
public static final int MFS_GRAYED = 0x3;
@@ -2166,6 +2167,26 @@ 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) {
@@ -2679,6 +2700,15 @@ 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);
@@ -3253,6 +3283,7 @@ 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)
@@ -3743,6 +3774,8 @@ 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);
@@ -4054,6 +4087,11 @@ 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)
@@ -4494,6 +4532,10 @@ 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