Skip to content

Commit 29f0f3c

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 ae0153c commit 29f0f3c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public abstract class Control extends Widget implements Drawable {
8282
/** Cache for currently processed DPI change event to be able to cancel it if a new one is triggered */
8383
Event currentDpiChangeEvent;
8484

85+
private static final String DATA_SHELL_ZOOM = "SHELL_ZOOM";
8586
/**
8687
* Prevents uninitialized instances from being created outside the package.
8788
*/
@@ -1260,6 +1261,15 @@ public Cursor getCursor () {
12601261
return cursor;
12611262
}
12621263

1264+
@Override
1265+
public Object getData(String key) {
1266+
if (DATA_SHELL_ZOOM.equals(key)) {
1267+
Shell shell = getShell();
1268+
return shell == null ? null : shell.nativeZoom;
1269+
}
1270+
return super.getData(key);
1271+
}
1272+
12631273
/**
12641274
* Returns <code>true</code> if the receiver is detecting
12651275
* 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

@@ -2727,9 +2725,7 @@ int getZoom() {
27272725
}
27282726

27292727
void handleDPIChange(Event event, float scalingFactor) {
2730-
int newZoom = event.detail;
2731-
this.nativeZoom = newZoom;
2732-
this.setData(DATA_NATIVE_ZOOM, newZoom);
2728+
this.nativeZoom = event.detail;
27332729
}
27342730

27352731
int getSystemMetrics(int nIndex) {

0 commit comments

Comments
 (0)