From 9d11600da0250bbf7bd2abfaba4ddcf53bdcdbad Mon Sep 17 00:00:00 2001 From: arunjose696 Date: Tue, 23 Dec 2025 16:26:41 +0100 Subject: [PATCH] Disposing and recreating menus menus when parent changes Menus, unlike controls, were not reparented when their associated part was moved (e.g., dragged to a different monitor). This caused menu icons and images to render at the wrong zoom due to the old parent's DPI. This change checks if a menu's parent has changed during rendering. If so, the menu is disposed and recreated under the correct parent, ensuring proper scaling and visual consistency across monitors. --- .../internal/workbench/swt/PartRenderingEngine.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java index cfcd37e51d0..97d26bacfc6 100644 --- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java +++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java @@ -99,8 +99,10 @@ import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Decorations; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Widget; import org.eclipse.ui.testing.TestableObject; @@ -583,6 +585,17 @@ public Object safeCreateGui(MUIElement element, Object parentWidget, } } + if (currentWidget instanceof Menu menu) { + if (parentWidget instanceof Decorations) { + Decorations currentParent = menu.getParent(); + if (currentParent != parentWidget) { + menu.dispose(); + return safeCreateGui(element, parentWidget, parentContext); + } + } + + } + // Reparent the context (or the kid's context) if (element instanceof MContext) { IEclipseContext ctxt = ((MContext) element).getContext();