diff options
author | Nikita Nemkin | 2018-04-25 07:44:35 +0000 |
---|---|---|
committer | Lars Vogel | 2018-05-03 06:56:57 +0000 |
commit | 9ee8b1444497d29c83291d4df9544a3f4d627fd3 (patch) | |
tree | cb2175bd771911bb828708954f396bbbce6f9124 | |
parent | b22eddae450ae63229cf4a039b6350de5194b568 (diff) | |
download | eclipse.platform.swt-9ee8b1444497d29c83291d4df9544a3f4d627fd3.tar.gz eclipse.platform.swt-9ee8b1444497d29c83291d4df9544a3f4d627fd3.tar.xz eclipse.platform.swt-9ee8b1444497d29c83291d4df9544a3f4d627fd3.zip |
Bug 534029 - [Win32] Simplify Display.getPrimaryMonitor()
Use the method suggested here:
https://blogs.msdn.microsoft.com/oldnewthing/20141106-00/?p=43683
Change-Id: I4479c8b50b8a98c14f7f8ea177381ee25269ea74
Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java | 2 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java | 22 |
2 files changed, 3 insertions, 21 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 4298683ac1..e2de419575 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 @@ -999,8 +999,8 @@ public class OS extends C { public static final int MM_TEXT = 0x1; public static final int MNC_CLOSE = 0x1; public static final int MNS_CHECKORBMP = 0x4000000; + public static final int MONITOR_DEFAULTTOPRIMARY = 0x1; public static final int MONITOR_DEFAULTTONEAREST = 0x2; - public static final int MONITORINFOF_PRIMARY = 0x1; public static final String MONTHCAL_CLASS = "SysMonthCal32"; //$NON-NLS-1$ public static final int MOUSEEVENTF_ABSOLUTE = 0x8000; public static final int MOUSEEVENTF_LEFTDOWN = 0x0002; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index d621b05f68..feb9016f3c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -2128,26 +2128,8 @@ long /*int*/ getMsgProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lP */ public Monitor getPrimaryMonitor () { checkDevice (); - monitors = new Monitor [4]; - Callback callback = new Callback (this, "monitorEnumProc", 4); //$NON-NLS-1$ - long /*int*/ lpfnEnum = callback.getAddress (); - if (lpfnEnum == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); - OS.EnumDisplayMonitors (0, null, lpfnEnum, 0); - callback.dispose (); - Monitor result = null; - MONITORINFO lpmi = new MONITORINFO (); - lpmi.cbSize = MONITORINFO.sizeof; - for (int i = 0; i < monitorCount; i++) { - Monitor monitor = monitors [i]; - OS.GetMonitorInfo (monitors [i].handle, lpmi); - if ((lpmi.dwFlags & OS.MONITORINFOF_PRIMARY) != 0) { - result = monitor; - break; - } - } - monitors = null; - monitorCount = 0; - return result; + long /*int*/ hmonitor = OS.MonitorFromWindow (0, OS.MONITOR_DEFAULTTOPRIMARY); + return getMonitor (hmonitor); } /** |