Skip to content

Commit f739d6a

Browse files
committed
[win32] Calculate value for NATIVE_ZOOM on demand
To remove the memory footprint of Widget this commit removes the value for NATIVE_ZOOM from the data attribute and replaces it by calculating the value in Control#getData on demand. Additionally the naming is changed to SHELL_ZOOM.
1 parent b2b5d45 commit f739d6a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public abstract class Control extends Widget implements Drawable {
7878
Font font;
7979
int drawCount, foreground, background, backgroundAlpha = 255;
8080

81+
private static final String DATA_SHELL_ZOOM = "SHELL_ZOOM";
82+
8183
/**
8284
* Prevents uninitialized instances from being created outside the package.
8385
*/
@@ -1256,6 +1258,15 @@ public Cursor getCursor () {
12561258
return cursor;
12571259
}
12581260

1261+
@Override
1262+
public Object getData(String key) {
1263+
if (DATA_SHELL_ZOOM.equals(key)) {
1264+
Shell shell = getShell();
1265+
return shell == null ? null : shell.nativeZoom;
1266+
}
1267+
return super.getData(key);
1268+
}
1269+
12591270
/**
12601271
* Returns <code>true</code> if the receiver is detecting
12611272
* drag gestures, and <code>false</code> otherwise.

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ public abstract class Widget {
134134
static final int AUTO_TEXT_DIRECTION = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
135135

136136
private static final String DATA_AUTOSCALE_DISABLED = "AUTOSCALE_DISABLED";
137-
private static final String DATA_NATIVE_ZOOM = "NATIVE_ZOOM";
138137

139138
/* Initialize the Common Controls DLL */
140139
static {
@@ -189,7 +188,6 @@ public Widget (Widget parent, int style) {
189188
display = parent.display;
190189
reskinWidget ();
191190
notifyCreationTracker();
192-
this.setData(DATA_NATIVE_ZOOM, this.nativeZoom);
193191
registerDPIChangeListener();
194192
}
195193

@@ -2725,9 +2723,7 @@ int getZoom() {
27252723
}
27262724

27272725
void handleDPIChange(Event event, float scalingFactor) {
2728-
int newZoom = event.detail;
2729-
this.nativeZoom = newZoom;
2730-
this.setData(DATA_NATIVE_ZOOM, newZoom);
2726+
this.nativeZoom = event.detail;
27312727
}
27322728

27332729
int getSystemMetrics(int nIndex) {

0 commit comments

Comments
 (0)