diff options
author | Niraj Modi | 2018-08-14 05:30:27 +0000 |
---|---|---|
committer | Niraj Modi | 2018-08-14 11:20:07 +0000 |
commit | 504c1f01f5fd7ad629d4d8642615b94b82d09857 (patch) | |
tree | b559e30ce374a902de11b359da5649c9a2ec7c03 /bundles | |
parent | b2cc595001b5dd056392e50a7db32df73516d8e4 (diff) | |
download | eclipse.platform.swt-504c1f01f5fd7ad629d4d8642615b94b82d09857.tar.gz eclipse.platform.swt-504c1f01f5fd7ad629d4d8642615b94b82d09857.tar.xz eclipse.platform.swt-504c1f01f5fd7ad629d4d8642615b94b82d09857.zip |
Bug 515502 - [HiDPI][Win10] SWT to receive/handle DPI changeI20180814-0900
notification from OS
Change-Id: Ic0b851b76cbd5b270f4d4337de6ac6f2fb81812c
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
Diffstat (limited to 'bundles')
4 files changed, 50 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/.settings/.api_filters b/bundles/org.eclipse.swt/.settings/.api_filters index bcc9c37500..2b7877280c 100644 --- a/bundles/org.eclipse.swt/.settings/.api_filters +++ b/bundles/org.eclipse.swt/.settings/.api_filters @@ -1227,6 +1227,12 @@ <message_argument value="OpenUrl"/> </message_arguments> </filter> + <filter id="336658481"> + <message_arguments> + <message_argument value="org.eclipse.swt.SWT"/> + <message_argument value="ZoomChanged"/> + </message_arguments> + </filter> <filter comment="@since 3.8 is valid in the 3.100 stream" id="1141899266"> <message_arguments> <message_argument value="3.8"/> 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 a7c4c48119..a9de9f7239 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1885,6 +1885,7 @@ public class OS extends C { public static final int WM_CUT = 0x300; public static final int WM_DEADCHAR = 0x103; public static final int WM_DESTROY = 0x2; + public static final int WM_DPICHANGED = 0x02E0; public static final int WM_DRAWITEM = 0x2b; public static final int WM_ENDSESSION = 0x16; public static final int WM_ENTERIDLE = 0x121; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java index ea709c0fb6..bec63ae242 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -856,6 +856,26 @@ public class SWT { */ public static final int OpenUrl = 54; + /** + * The SWT zoom change event type (value is 55). + * + * <p> + * This event is sent on <code>Shell</code> when the SWT zoom has changed. SWT + * zoom changes when the system DPI or scale factor changes dynamically. + * </p> + * <p> + * Note: This operation is a hint and is not supported on platforms that do not + * have this concept. Currently supported on Windows10 only. + * </p> + * + * @see org.eclipse.swt.widgets.Widget#addListener + * @see org.eclipse.swt.widgets.Display#addFilter + * @see org.eclipse.swt.widgets.Event + * + * @since 3.108 + */ + public static final int ZoomChanged = 55; + /* Event Details */ /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index e4e50d9bc5..a759761064 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -4855,6 +4855,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long / case OS.WM_XBUTTONDBLCLK: result = WM_XBUTTONDBLCLK (wParam, lParam); break; case OS.WM_XBUTTONDOWN: result = WM_XBUTTONDOWN (wParam, lParam); break; case OS.WM_XBUTTONUP: result = WM_XBUTTONUP (wParam, lParam); break; + case OS.WM_DPICHANGED: result = WM_DPICHANGED (wParam, lParam); break; } if (result != null) return result.value; // widget could be disposed at this point @@ -4937,6 +4938,25 @@ LRESULT WM_DESTROY (long /*int*/ wParam, long /*int*/ lParam) { return null; } +LRESULT WM_DPICHANGED (long /*int*/ wParam, long /*int*/ lParam) { + // Map DPI to Zoom and compare + int nativeZoom = DPIUtil.mapDPIToZoom (OS.HIWORD (wParam)); + int newSWTZoom = DPIUtil.getZoomForAutoscaleProperty (nativeZoom); + int oldSWTZoom = DPIUtil.getDeviceZoom(); + + // Throw the DPI change event if zoom value changes + if (newSWTZoom != oldSWTZoom) { + Event event = new Event(); + event.type = SWT.ZoomChanged; + event.widget = this; + event.detail = newSWTZoom; + event.doit = true; + notifyListeners(SWT.ZoomChanged, event); + return LRESULT.ZERO; + } + return LRESULT.ONE; +} + LRESULT WM_DRAWITEM (long /*int*/ wParam, long /*int*/ lParam) { DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT (); OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof); |