Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2018-07-05 07:49:15 +0000
committerNiraj Modi2018-07-05 07:49:15 +0000
commit70f886f0cc26a8a199e03705901d8179f0441a40 (patch)
treeb00a0cc9c750386adeb148b552cf7dbfe8e3df5e
parentbfe097e08d61473294019ac1daa3527388ac4baa (diff)
downloadeclipse.platform.swt-nmodi/DynamicDPI_4909.tar.gz
eclipse.platform.swt-nmodi/DynamicDPI_4909.tar.xz
eclipse.platform.swt-nmodi/DynamicDPI_4909.zip
Bug 534820 - [HiDPI][Win10][GTK] Support dynamic-scaling on DPI changenmodi/DynamicDPI_4909
- Display.getDeviceZoom now fetches Primary monitor's zoom on Win8.1 and above. - Code refactoring in Button/Label/Widget classes Change-Id: I7d0577b1a69937fb76eca43640b232fc865070f8 Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java5
4 files changed, 23 insertions, 19 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index 7ae45281a5..ba046e6aca 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -338,12 +338,7 @@ int computeLeftMargin () {
boolean hasImage = image != null, hasText = true;
if (hasImage) {
if (image != null) {
- // There exists a possibility of DPI change
- if (image.setZoom(this.currentDeviceZoom)) {
- _setImage(image);
- updateImageList();
- }
- Rectangle rect = image.getBounds(getShell().currentDeviceZoom);
+ Rectangle rect = image.getBounds(this.currentDeviceZoom);
width = rect.width;
if (hasText && text.length () != 0) {
width += MARGIN * 2;
@@ -1081,13 +1076,12 @@ public void setText (String string) {
@Override
public boolean setZoom (int zoom) {
boolean refreshed = super.setZoom (zoom);
+ this.currentDeviceZoom = zoom;
// Refresh the image
if(image != null) {
refreshed = image.setZoom (zoom);
- if (refreshed) {
- _setImage (image);
- updateImageList();
- }
+ _setImage (image);
+ updateImageList();
}
return refreshed;
}
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 3499e184b5..a7247ce0cf 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
@@ -2025,6 +2025,18 @@ Dialog getModalDialog () {
return modalDialog;
}
+/**
+ * @since 3.108
+ */
+@Override
+protected int getDeviceZoom() {
+ /* Win8.1 and above we pick zoom for the primary monitor zoom. */
+ if (OS.WIN32_VERSION >= OS.VERSION (6, 3)) {
+ return getPrimaryMonitor().getZoom();
+ }
+ return super.getDeviceZoom();
+}
+
Monitor getMonitor (long /*int*/ hmonitor) {
MONITORINFO lpmi = new MONITORINFO ();
lpmi.cbSize = MONITORINFO.sizeof;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index 6067693e39..aa0a5b3a1e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.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
@@ -129,14 +129,13 @@ static int checkStyle (int style) {
}
@Override
-boolean refreshControlForDPIChange() {
+public boolean setZoom (int zoom) {
boolean refreshed = false;
+ this.currentDeviceZoom = zoom;
// Refresh image on DPI change
if(image != null) {
refreshed = image.setZoom (this.currentDeviceZoom);
- if (refreshed) {
- setImage (image);
- }
+ setImage (image);
}
return refreshed;
}
@@ -161,8 +160,6 @@ boolean refreshControlForDPIChange() {
boolean drawImage = (bits & OS.SS_OWNERDRAW) == OS.SS_OWNERDRAW;
if (drawImage) {
if (image != null) {
- // There exists a possibility of DPI change
-// if (image.setZoom(this.currentDeviceZoom)) setImage (image);
Rectangle rect = image.getBounds(this.currentDeviceZoom);
width += rect.width;
height += rect.height;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index d3f6407e3e..d50dbb18a3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.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
@@ -46,7 +46,8 @@ import org.eclipse.swt.internal.win32.*;
*/
public abstract class Widget {
/**
- * s
+ * Specify current zoom level for the widget.
+ *
* @since 3.108
*/
protected int currentDeviceZoom = DPIUtil.getDeviceZoom();

Back to the top