diff options
author | Xi Yan | 2018-07-09 16:08:49 +0000 |
---|---|---|
committer | Xi Yan | 2018-07-09 16:08:49 +0000 |
commit | d5742ec2221f97fc3bd39b8b87463c655a3a1271 (patch) | |
tree | b280d4984fde911764c597401d98d8658026a14d /bundles/org.eclipse.swt/Eclipse SWT/gtk/org | |
parent | 927068fd24da295c63ec28c93994e63ed23b88d6 (diff) | |
download | eclipse.platform.swt-d5742ec2221f97fc3bd39b8b87463c655a3a1271.tar.gz eclipse.platform.swt-d5742ec2221f97fc3bd39b8b87463c655a3a1271.tar.xz eclipse.platform.swt-d5742ec2221f97fc3bd39b8b87463c655a3a1271.zip |
Bug 340752 - [GTK3] Control getSize() behaves different in Linux and
Windows. Getting wrong value on linux
Removed visible check in ExpandItem#resizeControl to set bounds for
items not expanded.
Change-Id: Ibb926eb7784113d5b800eb236d8432a35e6f9df5
Signed-off-by: Xi Yan <xixiyan@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java | 88 |
1 files changed, 43 insertions, 45 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java index 6e4882301d..dac7f768f6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java @@ -425,53 +425,51 @@ void releaseWidget () { void resizeControl (int yScroll) { if (control != null && !control.isDisposed ()) { boolean visible = GTK.gtk_expander_get_expanded (handle); - if (visible) { - GtkAllocation allocation = new GtkAllocation (); - GTK.gtk_widget_get_allocation (clientHandle, allocation); - - //454940 change in hierarchy - /* SWT's calls to gtk_widget_size_allocate and gtk_widget_set_allocation - * causes GTK+ to move the clientHandle's SwtFixed down by the size of the label. - * These calls can come up from 'shell' and ExpandItem has no control over these calls. - * This is an undesired side-effect. Client handle's x & y positions should never - * be incremented as this is an internal sub-container. - * As of GTK3, the hierarchy is changed, this affected child-size allocation and a fix - * is now neccessary. - * See also other 454940 notes and similar fix in: 453827 */ - int x = (GTK.GTK3) ? 0 : allocation.x; - int y = (GTK.GTK3) ? 0 : allocation.y; - - if (x != -1 && y != -1) { - int width = allocation.width; - int height = allocation.height; - int [] property = new int [1]; - GTK.gtk_widget_style_get (handle, OS.focus_line_width, property, 0); - y += property [0] * 2; - height -= property [0] * 2; - - /* - * Feature in GTK. When the ExpandBar is resize too small the control - * shows up on top of the vertical scrollbar. This happen because the - * GtkExpander does not set the size of child smaller than the request - * size of its parent and because the control is not parented in the - * hierarchy of the GtkScrolledWindow. - * The fix is calculate the width ourselves when the scrollbar is visible. - */ - ScrollBar vBar = parent.verticalBar; - if (vBar != null) { - if (GTK.gtk_widget_get_visible (vBar.handle)) { - GTK.gtk_widget_get_allocation (parent.scrolledHandle, allocation); - width = allocation.width - parent.vScrollBarWidth () - 2 * parent.spacing; - } - } - // Bug 479242: Bound calculation is correct without needing to use yScroll in GTK3 - if (GTK.GTK3) { - control.setBounds (x, y, width, Math.max (0, height), true, true); - } - else { - control.setBounds (x, y - yScroll, width, Math.max (0, height), true, true); + GtkAllocation allocation = new GtkAllocation (); + GTK.gtk_widget_get_allocation (clientHandle, allocation); + + //454940 change in hierarchy + /* SWT's calls to gtk_widget_size_allocate and gtk_widget_set_allocation + * causes GTK+ to move the clientHandle's SwtFixed down by the size of the label. + * These calls can come up from 'shell' and ExpandItem has no control over these calls. + * This is an undesired side-effect. Client handle's x & y positions should never + * be incremented as this is an internal sub-container. + * As of GTK3, the hierarchy is changed, this affected child-size allocation and a fix + * is now neccessary. + * See also other 454940 notes and similar fix in: 453827 */ + int x = (GTK.GTK3) ? 0 : allocation.x; + int y = (GTK.GTK3) ? 0 : allocation.y; + + if (x != -1 && y != -1) { + int width = allocation.width; + int height = allocation.height; + int [] property = new int [1]; + GTK.gtk_widget_style_get (handle, OS.focus_line_width, property, 0); + y += property [0] * 2; + height -= property [0] * 2; + + /* + * Feature in GTK. When the ExpandBar is resize too small the control + * shows up on top of the vertical scrollbar. This happen because the + * GtkExpander does not set the size of child smaller than the request + * size of its parent and because the control is not parented in the + * hierarchy of the GtkScrolledWindow. + * The fix is calculate the width ourselves when the scrollbar is visible. + */ + ScrollBar vBar = parent.verticalBar; + if (vBar != null) { + if (GTK.gtk_widget_get_visible (vBar.handle)) { + GTK.gtk_widget_get_allocation (parent.scrolledHandle, allocation); + width = allocation.width - parent.vScrollBarWidth () - 2 * parent.spacing; } } + // Bug 479242: Bound calculation is correct without needing to use yScroll in GTK3 + if (GTK.GTK3) { + control.setBounds (x, y, width, Math.max (0, height), true, true); + } + else { + control.setBounds (x, y - yScroll, width, Math.max (0, height), true, true); + } } control.setVisible (visible); } |