Skip to content

Commit 4b8c0fd

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.
1 parent 75c97fd commit 4b8c0fd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
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
@@ -82,6 +82,8 @@ public abstract class Control extends Widget implements Drawable {
8282
Font font;
8383
int drawCount, foreground, background, backgroundAlpha = 255;
8484

85+
private static final String DATA_NATIVE_ZOOM = "NATIVE_ZOOM";
86+
8587
/**
8688
* Prevents uninitialized instances from being created outside the package.
8789
*/
@@ -1258,6 +1260,15 @@ public Cursor getCursor () {
12581260
return cursor;
12591261
}
12601262

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

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

Lines changed: 0 additions & 3 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 {
@@ -190,7 +189,6 @@ public Widget (Widget parent, int style) {
190189
display = parent.display;
191190
reskinWidget ();
192191
notifyCreationTracker();
193-
this.setData(DATA_NATIVE_ZOOM, this.nativeZoom);
194192
}
195193

196194
void _addListener (int eventType, Listener listener) {
@@ -2719,7 +2717,6 @@ int getZoom() {
27192717

27202718
private static void handleDPIChange(Widget widget, int newZoom, float scalingFactor) {
27212719
widget.nativeZoom = newZoom;
2722-
widget.setData(DATA_NATIVE_ZOOM, newZoom);
27232720
}
27242721

27252722
int getSystemMetrics(int nIndex) {

0 commit comments

Comments
 (0)