Skip to content

Commit cb3cc53

Browse files
committed
WIP
1 parent fb71f1f commit cb3cc53

File tree

7 files changed

+54
-23
lines changed

7 files changed

+54
-23
lines changed

binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
33
Bundle-Name: %fragmentName
44
Bundle-Vendor: %providerName
55
Bundle-SymbolicName: org.eclipse.swt.win32.win32.x86_64; singleton:=true
6-
Bundle-Version: 3.133.0.qualifier
6+
Bundle-Version: 3.132.0.qualifier
77
Bundle-ManifestVersion: 2
88
Bundle-Localization: fragment
99
Export-Package:

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,6 +3527,13 @@ NSTouch findTouchWithId(NSArray touches, NSObject identity) {
35273527
return null;
35283528
}
35293529

3530+
/**
3531+
* @since 3.132
3532+
*/
3533+
public boolean setAutoscaleDisabled(boolean autoscaleDisabled) {
3534+
return false;
3535+
}
3536+
35303537
void setBackground () {
35313538
if (!drawsBackground()) return;
35323539
Control control = findBackgroundControl ();

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import org.eclipse.swt.*;
1919
import org.eclipse.swt.events.*;
2020
import org.eclipse.swt.graphics.*;
21+
import org.eclipse.swt.internal.*;
2122
import org.eclipse.swt.internal.cocoa.*;
23+
import org.eclipse.swt.internal.win32.*;
2224

2325
/**
2426
* Instances of this class represent the "windows"
@@ -1976,6 +1978,10 @@ public void setModified (boolean modified) {
19761978
window.setDocumentEdited (modified);
19771979
}
19781980

1981+
public int getNativeZoom() {
1982+
return DPIUtil.getNativeDeviceZoom();
1983+
}
1984+
19791985
/**
19801986
* Sets the shape of the shell to the region specified
19811987
* by the argument. When the argument is null, the
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.eclipse.swt.graphics;
2+
3+
public enum AutoscalingMode {
4+
ENABLED,
5+
DISABLED,
6+
DISABLED_INHERITED
7+
}

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,6 +2796,11 @@ public void setModified (boolean modified) {
27962796
this.modified = modified;
27972797
}
27982798

2799+
2800+
public int getNativeZoom() {
2801+
return DPIUtil.getNativeDeviceZoom();
2802+
}
2803+
27992804
/**
28002805
* Sets the shape of the shell to the region specified
28012806
* by the argument. When the argument is null, the

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,9 @@ public abstract class Control extends Widget implements Drawable {
7777
Region region;
7878
Font font;
7979
int drawCount, foreground, background, backgroundAlpha = 255;
80-
boolean autoScaleDisabled = false;
80+
AutoscalingMode autoscalingMode = AutoscalingMode.ENABLED;
8181

8282
private static final String DATA_SHELL_ZOOM = "SHELL_ZOOM";
83-
84-
private static final String DATA_AUTOSCALE_DISABLED = "AUTOSCALE_DISABLED";
85-
86-
private static final String PROPOGATE_AUTOSCALE_DISABLED = "PROPOGATE_AUTOSCALE_DISABLED";
8783
/**
8884
* Prevents uninitialized instances from being created outside the package.
8985
*/
@@ -123,11 +119,11 @@ public abstract class Control extends Widget implements Drawable {
123119
public Control (Composite parent, int style) {
124120
super (parent, style);
125121
this.parent = parent;
126-
Boolean parentPropagateAutoscaleDisabled = (Boolean) parent.getData(PROPOGATE_AUTOSCALE_DISABLED);
127-
if (parentPropagateAutoscaleDisabled == null || parentPropagateAutoscaleDisabled) {
128-
this.autoScaleDisabled = parent.autoScaleDisabled;
122+
AutoscalingMode parentAutoscaleMode = parent.autoscalingMode;
123+
if (parentAutoscaleMode == AutoscalingMode.DISABLED_INHERITED) {
124+
this.autoscalingMode = parent.autoscalingMode;
129125
}
130-
if (!autoScaleDisabled) {
126+
if (isAutoScalable()) {
131127
this.nativeZoom = getShellZoom();
132128
}
133129
createWidget ();
@@ -1282,19 +1278,6 @@ public Object getData(String key) {
12821278
return super.getData(key);
12831279
}
12841280

1285-
@Override
1286-
public void setData(String key, Object value) {
1287-
super.setData(key, value);
1288-
if (DATA_AUTOSCALE_DISABLED.equals(key)) {
1289-
autoScaleDisabled = Boolean.parseBoolean(value.toString());
1290-
if (autoScaleDisabled) {
1291-
this.nativeZoom = 100;
1292-
} else {
1293-
this.nativeZoom = getShellZoom();
1294-
}
1295-
}
1296-
}
1297-
12981281
/**
12991282
* Returns <code>true</code> if the receiver is detecting
13001283
* drag gestures, and <code>false</code> otherwise.
@@ -1873,6 +1856,11 @@ boolean isActive () {
18731856
return shell.getEnabled ();
18741857
}
18751858

1859+
@Override
1860+
public boolean isAutoScalable() {
1861+
return autoscalingMode == AutoscalingMode.ENABLED;
1862+
}
1863+
18761864
/**
18771865
* Returns <code>true</code> if the receiver is enabled and all
18781866
* ancestors up to and including the receiver's nearest ancestor
@@ -3352,6 +3340,19 @@ private void fitInParentBounds(Rectangle boundsInPixels, int zoom) {
33523340
}
33533341
}
33543342

3343+
/**
3344+
* @since 3.132
3345+
*/
3346+
public boolean setAutoscalingMode(AutoscalingMode autoscalingMode) {
3347+
this.autoscalingMode = autoscalingMode;
3348+
if (!isAutoScalable()) {
3349+
this.nativeZoom = 100;
3350+
} else {
3351+
this.nativeZoom = getShellZoom();
3352+
}
3353+
return true;
3354+
}
3355+
33553356
void setBoundsInPixels (Rectangle rect) {
33563357
setBoundsInPixels (rect.x, rect.y, rect.width, rect.height);
33573358
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,11 @@ public ToolBar getToolBar() {
12331233
return null;
12341234
}
12351235

1236+
@Override
1237+
public int getNativeZoom() {
1238+
return DPIUtil.mapDPIToZoom(OS.GetDpiForWindow(handle));
1239+
}
1240+
12361241
@Override
12371242
Composite findDeferredControl () {
12381243
return layoutCount > 0 ? this : null;

0 commit comments

Comments
 (0)