Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-12-19 17:24:51 +0000
committerXi Yan2018-12-19 20:57:08 +0000
commit95867ff143b29c24bae92e63e8877c097914cb5d (patch)
tree67c0c06d59f66fdd20581d82e50b226ae3838a68
parent3c2c84010e869bca54123f5d34124263c4b93ac7 (diff)
downloadeclipse.platform.swt-95867ff143b29c24bae92e63e8877c097914cb5d.tar.gz
eclipse.platform.swt-95867ff143b29c24bae92e63e8877c097914cb5d.tar.xz
eclipse.platform.swt-95867ff143b29c24bae92e63e8877c097914cb5d.zip
Bug 542926 - [GTK3] Combo has incorrect initial size
Using gtk_widget_size_allocate (only works for GtkContainer on GTK3) for Combo#setInitialBounds does not assign the correct size. Use gtk_widget_set_allocation instead to set the correct initial size for Combo. Change-Id: I2a31e1d91dc0724f350ce32c0eb9866ab010d80b Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index d969c321b4..6be8f47936 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -2255,6 +2255,34 @@ void setForegroundGdkRGBA (GdkRGBA rgba) {
super.setForegroundGdkRGBA(rgba);
}
+@Override
+void setInitialBounds () {
+ if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) {
+ /*
+ * Feature in GTK. On creation, each widget's allocation is
+ * initialized to a position of (-1, -1) until the widget is
+ * first sized. The fix is to set the value to (0, 0) as
+ * expected by SWT.
+ */
+ long /*int*/ topHandle = topHandle ();
+ GtkAllocation allocation = new GtkAllocation();
+ if ((parent.style & SWT.MIRRORED) != 0) {
+ allocation.x = parent.getClientWidth ();
+ } else {
+ allocation.x = 0;
+ }
+ allocation.y = 0;
+ GTK.gtk_widget_set_visible(topHandle, true);
+ if (GTK.GTK4) {
+ GTK.gtk_widget_size_allocate (topHandle, allocation, -1);
+ } else {
+ GTK.gtk_widget_set_allocation(topHandle, allocation);
+ }
+ } else {
+ super.setInitialBounds();
+ }
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument.

Back to the top