From 29f0f3cdac8c0e6837b18283f17ea07d3fbc17ad Mon Sep 17 00:00:00 2001 From: Andreas Koch Date: Wed, 17 Sep 2025 13:23:52 +0200 Subject: [PATCH] [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. --- .../win32/org/eclipse/swt/widgets/Control.java | 10 ++++++++++ .../win32/org/eclipse/swt/widgets/Widget.java | 6 +----- 2 files changed, 11 insertions(+), 5 deletions(-) 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 36b8b7a01f..bcfd141fe0 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 @@ -82,6 +82,7 @@ public abstract class Control extends Widget implements Drawable { /** Cache for currently processed DPI change event to be able to cancel it if a new one is triggered */ Event currentDpiChangeEvent; + private static final String DATA_SHELL_ZOOM = "SHELL_ZOOM"; /** * Prevents uninitialized instances from being created outside the package. */ @@ -1260,6 +1261,15 @@ public Cursor getCursor () { return cursor; } +@Override +public Object getData(String key) { + if (DATA_SHELL_ZOOM.equals(key)) { + Shell shell = getShell(); + return shell == null ? null : shell.nativeZoom; + } + return super.getData(key); +} + /** * Returns true if the receiver is detecting * drag gestures, and false otherwise. diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java index ad2d66abf4..ac9cea0833 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java @@ -134,7 +134,6 @@ public abstract class Widget { static final int AUTO_TEXT_DIRECTION = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; private static final String DATA_AUTOSCALE_DISABLED = "AUTOSCALE_DISABLED"; - private static final String DATA_NATIVE_ZOOM = "NATIVE_ZOOM"; /* Initialize the Common Controls DLL */ static { @@ -189,7 +188,6 @@ public Widget (Widget parent, int style) { display = parent.display; reskinWidget (); notifyCreationTracker(); - this.setData(DATA_NATIVE_ZOOM, this.nativeZoom); registerDPIChangeListener(); } @@ -2727,9 +2725,7 @@ int getZoom() { } void handleDPIChange(Event event, float scalingFactor) { - int newZoom = event.detail; - this.nativeZoom = newZoom; - this.setData(DATA_NATIVE_ZOOM, newZoom); + this.nativeZoom = event.detail; } int getSystemMetrics(int nIndex) {