Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-08-28 21:11:27 +0000
committerXi Yan2018-09-07 13:46:40 +0000
commit02a73627d82970a22db1a3f3dbcd2eeca9037612 (patch)
tree71d60477682c366922865e0f82a4a2c986aeb34c
parent876fd1579880be4f9c673e658ee0f6acec76f468 (diff)
downloadeclipse.platform.swt-02a73627d82970a22db1a3f3dbcd2eeca9037612.tar.gz
eclipse.platform.swt-02a73627d82970a22db1a3f3dbcd2eeca9037612.tar.xz
eclipse.platform.swt-02a73627d82970a22db1a3f3dbcd2eeca9037612.zip
Bug 533469 - [GTK3] Ghost button since upgrade to GTK 3.22
On GTK3.19+, widget are forced to be allocated the default minimum size regardless of the size of the fixed container, introduced after GTK commit 3e069428. This causes widgets with 0x0 size to be visible but unusable. The fix is to make 0x0 widgets invisible to the user explicitly using gtk_widget_hide. Resizing widget to a non-zero size later on shows the widget in setBounds. Tested with snippet, empty shell when size of Control were not set. No ghost button on Papyrus Property dialog. Change-Id: I6e47d838c3a4679e5b8f2140601b23ca57e13ee7 Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java9
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug533469_GhostButton.java47
2 files changed, 56 insertions, 0 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 d679d761e9..86e5fdec6e 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
@@ -3668,6 +3668,15 @@ long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
GdkRectangle rect = new GdkRectangle ();
GDK.gdk_cairo_get_clip_rectangle (cairo, rect);
/*
+ * On GTK3.19+, widget are are shown with the default minimum size regardless of the
+ * size of the fixed container. This causes 0x0 widgets to be visible but cannot be used.
+ * The fix is to make the widget invisible to the user. Resizing widget later on to a larger size
+ * makes the widget visible again in setBounds. See Bug 533469, Bug 531120.
+ */
+ if (GTK.GTK_VERSION > OS.VERSION (3, 18, 0) && (state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) {
+ if (GTK.gtk_widget_get_visible(widget)) GTK.gtk_widget_hide(widget);
+ }
+ /*
* Modify the drawing of the widget with cairo_clip.
* Doesn't modify input handling at this time.
* See bug 529431.
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug533469_GhostButton.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug533469_GhostButton.java
new file mode 100644
index 0000000000..d6b32410ef
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug533469_GhostButton.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * On GTK3.18: Empty Shell
+ * On GTK3.20+: Button/Text/etc is visible when size is 0x0
+ */
+public class Bug533469_GhostButton {
+ public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell(display);
+
+ Button button = new Button(shell, SWT.None);
+ button.setText("Hi"); // size is not set, it should be 0x0
+// button.setSize(100, 100);
+
+// Text text = new Text(shell, SWT.None);
+// text.setText("Hello");
+// text.setSize(100, 100);
+
+// System.out.println(button.getSize());
+
+ shell.setSize(300, 300);
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}

Back to the top