diff --git a/binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF index c11df99a832..84f618f2b6a 100644 --- a/binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF +++ b/binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)" Bundle-Name: %fragmentName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.swt.win32.win32.x86_64; singleton:=true -Bundle-Version: 3.133.0.qualifier +Bundle-Version: 3.132.0.qualifier Bundle-ManifestVersion: 2 Bundle-Localization: fragment Export-Package: diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java index 1bd2ff7879c..7a08b7e504c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java @@ -3527,6 +3527,13 @@ NSTouch findTouchWithId(NSArray touches, NSObject identity) { return null; } +/** + * @since 3.132 + */ +public boolean setAutoscaleDisabled(boolean autoscaleDisabled) { + return false; +} + void setBackground () { if (!drawsBackground()) return; Control control = findBackgroundControl (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java index 5c7cc8e9936..80484ab4455 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java @@ -18,7 +18,9 @@ import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cocoa.*; +import org.eclipse.swt.internal.win32.*; /** * Instances of this class represent the "windows" @@ -1976,6 +1978,10 @@ public void setModified (boolean modified) { window.setDocumentEdited (modified); } +public int getNativeZoom() { + return DPIUtil.getNativeDeviceZoom(); +} + /** * Sets the shape of the shell to the region specified * by the argument. When the argument is null, the diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/AutoscalingMode.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/AutoscalingMode.java new file mode 100644 index 00000000000..87b981ab97d --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/AutoscalingMode.java @@ -0,0 +1,7 @@ +package org.eclipse.swt.graphics; + +public enum AutoscalingMode { + ENABLED, + DISABLED, + DISABLED_INHERITED +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index 47213b864c8..bfe18f81884 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -5143,6 +5143,13 @@ void gtk_label_set_align(long label, float xAlign, float yAlign) { GTK.gtk_label_set_yalign(label, yAlign); } +/** + * @since 3.132 + */ +public boolean setAutoscaleDisabled(boolean autoscaleDisabled) { + return false; +} + void setBackground () { if ((state & BACKGROUND) == 0 && backgroundImage == null) { if ((state & PARENT_BACKGROUND) != 0) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index 27f141eeaa1..008b5930808 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -2796,6 +2796,11 @@ public void setModified (boolean modified) { this.modified = modified; } + +public int getNativeZoom() { + return DPIUtil.getNativeDeviceZoom(); +} + /** * Sets the shape of the shell to the region specified * by the argument. When the argument is null, the 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 be30cc3da5c..a0a0491ee25 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 @@ -77,7 +77,7 @@ public abstract class Control extends Widget implements Drawable { Region region; Font font; int drawCount, foreground, background, backgroundAlpha = 255; - boolean autoScaleDisabled = false; + AutoscalingMode autoscalingMode = AutoscalingMode.ENABLED; private static final String DATA_SHELL_ZOOM = "SHELL_ZOOM"; @@ -123,11 +123,11 @@ public abstract class Control extends Widget implements Drawable { public Control (Composite parent, int style) { super (parent, style); this.parent = parent; - Boolean parentPropagateAutoscaleDisabled = (Boolean) parent.getData(PROPOGATE_AUTOSCALE_DISABLED); - if (parentPropagateAutoscaleDisabled == null || parentPropagateAutoscaleDisabled) { - this.autoScaleDisabled = parent.autoScaleDisabled; + AutoscalingMode parentAutoscaleMode = parent.autoscalingMode; + if (parentAutoscaleMode == AutoscalingMode.DISABLED_INHERITED) { + this.autoscalingMode = parent.autoscalingMode; } - if (!autoScaleDisabled) { + if (isAutoScalable()) { this.nativeZoom = getShellZoom(); } createWidget (); @@ -1285,11 +1285,14 @@ public Object getData(String key) { @Override public void setData(String key, Object value) { super.setData(key, value); - if (DATA_AUTOSCALE_DISABLED.equals(key)) { - autoScaleDisabled = Boolean.parseBoolean(value.toString()); + if (DATA_AUTOSCALE_DISABLED.equals(key) || PROPOGATE_AUTOSCALE_DISABLED.equals(key)) { + boolean autoScaleDisabled = Boolean.parseBoolean(getData(DATA_AUTOSCALE_DISABLED).toString()); + boolean propagateAutoscaleDisabled = Boolean.parseBoolean(getData(PROPOGATE_AUTOSCALE_DISABLED).toString()); if (autoScaleDisabled) { + autoscalingMode = propagateAutoscaleDisabled ? AutoscalingMode.DISABLED_INHERITED : AutoscalingMode.DISABLED; this.nativeZoom = 100; } else { + autoscalingMode = AutoscalingMode.ENABLED; this.nativeZoom = getShellZoom(); } } @@ -1873,6 +1876,11 @@ boolean isActive () { return shell.getEnabled (); } +@Override +public boolean isAutoScalable() { + return autoscalingMode == AutoscalingMode.ENABLED; +} + /** * Returns true if the receiver is enabled and all * ancestors up to and including the receiver's nearest ancestor @@ -3352,6 +3360,19 @@ private void fitInParentBounds(Rectangle boundsInPixels, int zoom) { } } +/** + * @since 3.132 + */ +public boolean setAutoscalingMode(AutoscalingMode autoscalingMode) { + this.autoscalingMode = autoscalingMode; + if (!isAutoScalable()) { + this.nativeZoom = 100; + } else { + this.nativeZoom = getShellZoom(); + } + return true; +} + void setBoundsInPixels (Rectangle rect) { setBoundsInPixels (rect.x, rect.y, rect.width, rect.height); } @@ -4865,7 +4886,7 @@ public boolean setParent (Composite parent) { @Override GC createNewGC(long hDC, GCData data) { data.nativeZoom = getNativeZoom(); - if (autoScaleDisabled && data.font != null) { + if (!isAutoScalable() && data.font != null) { data.font = SWTFontProvider.getFont(display, data.font.getFontData()[0], 100); } return GC.win32_new(hDC, data); @@ -4873,7 +4894,7 @@ GC createNewGC(long hDC, GCData data) { @Override int getZoom() { - if (autoScaleDisabled) { + if (!isAutoScalable()) { return 100; } return super.getZoom(); @@ -4887,7 +4908,7 @@ int getShellZoom() { } private int computeGetBoundsZoom() { - if (parent != null && !autoScaleDisabled) { + if (parent != null && isAutoScalable()) { return parent.getZoom(); } return getZoom(); @@ -6035,7 +6056,7 @@ void sendZoomChangedEvent(Event event, Shell shell) { @Override void handleDPIChange(Event event, float scalingFactor) { super.handleDPIChange(event, scalingFactor); - if (this.autoScaleDisabled) { + if (!this.isAutoScalable()) { this.nativeZoom = 100; } resizeFont(this, getNativeZoom()); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java index 11ee9778826..316f6f51b4f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java @@ -1233,6 +1233,11 @@ public ToolBar getToolBar() { return null; } +@Override +public int getNativeZoom() { + return DPIUtil.mapDPIToZoom(OS.GetDpiForWindow(handle)); +} + @Override Composite findDeferredControl () { return layoutCount > 0 ? this : null;