diff options
| author | Eric Williams | 2018-03-05 20:36:50 +0000 |
|---|---|---|
| committer | Eric Williams | 2018-03-05 21:46:51 +0000 |
| commit | 1ec7502cc45b6662d6d7ef7aa41c7cf1a861b574 (patch) | |
| tree | 3e375e14e6c95df64e0026d6be5cba131fe99326 | |
| parent | 81d20050ef966e10367d42e4537769aa06b260b8 (diff) | |
| download | eclipse.platform.swt-1ec7502cc45b6662d6d7ef7aa41c7cf1a861b574.tar.gz eclipse.platform.swt-1ec7502cc45b6662d6d7ef7aa41c7cf1a861b574.tar.xz eclipse.platform.swt-1ec7502cc45b6662d6d7ef7aa41c7cf1a861b574.zip | |
Bug 530317: [GTK3.20+] Java formatter editor has cut-off buttons
This bug is caused by a corner case where the minimum size is larger
than the natural size. In these cases the widget will end up too large,
as only the minimum size is taken into account.
When performing sizing calculations for GTK3.20+, use the smallest of
the minimum and natural sizes to prevent oversized widgets.
Tested on GTK3.20+ using Eclipse and the AllNonBrowser JUnit tests. No
additional allocation warnings are printed in the console.
Change-Id: I30a7ef75abb135b1a23402a834824241b6eb055f
Signed-off-by: Eric Williams <ericwill@redhat.com>
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index 2debaf6c63..8febb913cc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -1036,10 +1036,17 @@ Point resizeCalculationsGTK3 (long /*int*/ widget, int width, int height) { * these elements is < 0, allocate the preferred size instead. See bug 486068. */ if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - GtkRequisition requisition = new GtkRequisition(); - GTK.gtk_widget_get_preferred_size(widget, requisition, null); - sizes.x = (width - (requisition.width - width)) < 0 ? requisition.width : width; - sizes.y = (height - (requisition.height - height)) < 0 ? requisition.height : height; + GtkRequisition minimumSize = new GtkRequisition(); + GtkRequisition naturalSize = new GtkRequisition(); + GTK.gtk_widget_get_preferred_size(widget, minimumSize, naturalSize); + /* + * Use the smallest of the minimum/natural sizes to prevent oversized + * widgets. + */ + int smallestWidth = Math.min(minimumSize.width, naturalSize.width); + int smallestHeight = Math.min(minimumSize.height, naturalSize.height); + sizes.x = (width - (smallestWidth - width)) < 0 ? smallestWidth : width; + sizes.y = (height - (smallestHeight - height)) < 0 ? smallestHeight : height; } return sizes; } |
