Skip to content

Commit 9d11600

Browse files
committed
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.
1 parent 4976c3a commit 9d11600

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@
9999
import org.eclipse.swt.events.ShellEvent;
100100
import org.eclipse.swt.widgets.Composite;
101101
import org.eclipse.swt.widgets.Control;
102+
import org.eclipse.swt.widgets.Decorations;
102103
import org.eclipse.swt.widgets.Display;
103104
import org.eclipse.swt.widgets.Listener;
105+
import org.eclipse.swt.widgets.Menu;
104106
import org.eclipse.swt.widgets.Shell;
105107
import org.eclipse.swt.widgets.Widget;
106108
import org.eclipse.ui.testing.TestableObject;
@@ -583,6 +585,17 @@ public Object safeCreateGui(MUIElement element, Object parentWidget,
583585
}
584586
}
585587

588+
if (currentWidget instanceof Menu menu) {
589+
if (parentWidget instanceof Decorations) {
590+
Decorations currentParent = menu.getParent();
591+
if (currentParent != parentWidget) {
592+
menu.dispose();
593+
return safeCreateGui(element, parentWidget, parentContext);
594+
}
595+
}
596+
597+
}
598+
586599
// Reparent the context (or the kid's context)
587600
if (element instanceof MContext) {
588601
IEclipseContext ctxt = ((MContext) element).getContext();

0 commit comments

Comments
 (0)