From cfba1995a8302bc1e9402fd5da9fbcac6ab97d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Paku=C5=82a?= Date: Tue, 10 Oct 2023 21:19:43 +0200 Subject: [PATCH] Fix eclipse-platform/eclipse.platform#1173 - bad UI on MacOS merge viewer (#732) Implement ContentMergeViewer.computeSize and run toolbar updated async --- .../ContentMergeViewer.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java index 01a6f2bd58b..e0a0c2064da 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java @@ -78,6 +78,7 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Sash; import org.eclipse.swt.widgets.Shell; @@ -126,8 +127,15 @@ public abstract class ContentMergeViewer extends ContentViewer private class ContentMergeViewerLayout extends Layout { @Override - public Point computeSize(Composite c, int w, int h, boolean force) { - return new Point(100, 100); + public Point computeSize(Composite composite, int wHint, int hHint, boolean force) { + if (hHint > SWT.DEFAULT && wHint > SWT.DEFAULT) { + return new Point(wHint, hHint); + } + + Rectangle r = composite.getClientArea(); + + + return new Point(r.width, r.height); } @Override @@ -797,8 +805,12 @@ private void internalRefresh(Object input) { ToolBarManager tbm = (ToolBarManager) getToolBarManager(fComposite.getParent()); if (tbm != null ) { updateToolItems(); - tbm.update(true); - tbm.getControl().getParent().layout(true); + Display.getDefault().asyncExec(() -> { + // relayout in next tick + tbm.update(true); + tbm.getControl().getParent().setRedraw(true); + }); + } } }