diff options
| author | Andrey Loskutov | 2018-10-31 12:23:10 +0000 |
|---|---|---|
| committer | Andrey Loskutov | 2018-11-05 16:00:05 +0000 |
| commit | 6ebcb89907ca02f035b4773c6409ad79aabc4b72 (patch) | |
| tree | c8f6496f1caedd054afcef9bb337fa2d3aadd585 | |
| parent | f23577f6c6622ec6291ce641439c3c80d35e9ca5 (diff) | |
| download | eclipse.platform.swt-6ebcb89907ca02f035b4773c6409ad79aabc4b72.tar.gz eclipse.platform.swt-6ebcb89907ca02f035b4773c6409ad79aabc4b72.tar.xz eclipse.platform.swt-6ebcb89907ca02f035b4773c6409ad79aabc4b72.zip | |
Bug 540298 - adressing initial widget size/visibility issues
This is an attempt to fix bug 533469 (and the side effect of it caused
bug 540298), by removing the workaround for setInitialBounds() coming
from GTK2 days, where SWT set the widget bounds AND visibility to the
newly created widgets with state containing ZERO_WIDTH and ZERO_HEIGHT
flags.
On GTK 3.20+ this seem to cause troubles resulting in ghost buttons
shown.
NOTE: this patch does not fix the Group widget to be shown even if the
widget size is not set (similar to bug 540298). To fix it,
Group.mustBeVisibleOnInitBounds() should return false. However, this
breaks Group size or layout, so that many groups with widgets are "too
small" to show the last widget.
Change-Id: I10d56b0acf8d063e83b3230b3e99cdd84455804b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java | 29 | ||||
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java | 8 |
2 files changed, 27 insertions, 10 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 d91e064204..d8f4e0f208 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 @@ -3449,15 +3449,7 @@ long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) { if ((state & OBSCURED) != 0) return 0; 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. @@ -4954,13 +4946,19 @@ void setForegroundGdkRGBA (long /*int*/ handle, GdkRGBA rgba) { void setInitialBounds () { if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) { + long /*int*/ topHandle = topHandle (); + if(GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) { + if(mustBeVisibleOnInitBounds()) { + GTK.gtk_widget_set_visible(topHandle, true); + } + return; + } /* * 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 (); @@ -4976,6 +4974,17 @@ void setInitialBounds () { } } +/** + * Widgets with unusual bounds calculation behavior can override this method + * to return {@code true} if the widged must be visible during call to + * {@link #setInitialBounds()}. + * + * @return {@code false} by default on modern GTK 3 versions (3.20+). + */ +boolean mustBeVisibleOnInitBounds() { + return GTK.GTK_VERSION < OS.VERSION(3, 20, 0); +} + /* * Sets the receivers Drag Gestures in order to do drag detection correctly for * X11/Wayland window managers after GTK3.14. diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java index b70fa33752..8c3ab21fdc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java @@ -108,6 +108,14 @@ long /*int*/ clientHandle () { } @Override +boolean mustBeVisibleOnInitBounds() { + // Bug 540298: if we return false, we will be invisible if the size is + // not set, but our layout will not properly work, so that not all children + // will be shown properly + return true; +} + +@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) { Point size = super.computeSizeInPixels(wHint, hHint, changed); int width = computeNativeSize (handle, SWT.DEFAULT, SWT.DEFAULT, false).x; |
