diff options
author | Eric Williams | 2018-05-30 18:31:33 +0000 |
---|---|---|
committer | Eric Williams | 2018-06-06 20:05:49 +0000 |
commit | 820c46cbb7018b48aa8791ca34c8025246bda964 (patch) | |
tree | bfa0211d69d8f6e459047d13a329636acfd11643 /bundles | |
parent | 05a9e389988d0135e5257c26f362880d3b1750af (diff) | |
download | eclipse.platform.swt-820c46cbb7018b48aa8791ca34c8025246bda964.tar.gz eclipse.platform.swt-820c46cbb7018b48aa8791ca34c8025246bda964.tar.xz eclipse.platform.swt-820c46cbb7018b48aa8791ca34c8025246bda964.zip |
Bug 319612: [Gtk] Shell.getSize() returns wrong value when created with
style SWT.RESIZE | SWT.ON_TOP
Ignore hardcoded trim when calculating sizes for shells with SWT.ON_TOP
and SWT.RESIZE set (i.e. "custom resize" shells). These shells already
use border as set by gtk_container_set_border_width() -- subtracting the
trimming in Shell.setBounds() is unnecessary.
Tested on GTK3.22 on X11 and Wayland. A JUnit test case to reproduce the
issue is attached. No AllNonBrowser JUnit tests fail.
Change-Id: I81ebd319b623dfb3b98c533996a43e6435e80d2f
Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index 636f30cc7b..01d89b3dbf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -489,8 +489,11 @@ void adjustTrim () { * Bug in GTK. gdk_window_get_frame_extents() fails for various window * managers, causing a large incorrect value to be returned as the trim. * The fix is to ignore the returned trim values if they are too large. + * + * Additionally, ignore trim for Shells with SWT.RESIZE and SWT.ON_TOP set. + * See bug 319612. */ - if (trimWidth > MAXIMUM_TRIM || trimHeight > MAXIMUM_TRIM) { + if (trimWidth > MAXIMUM_TRIM || trimHeight > MAXIMUM_TRIM || isCustomResize()) { display.ignoreTrim = true; return; } @@ -686,10 +689,7 @@ Rectangle computeTrimInPixels (int x, int y, int width, int height) { checkWidget(); Rectangle trim = super.computeTrimInPixels (x, y, width, height); int border = 0; - if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) { - border = GTK.gtk_container_get_border_width (shellHandle); - } - if (isCustomResize ()) { + if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0 || isCustomResize()) { border = GTK.gtk_container_get_border_width (shellHandle); } int trimWidth = trimWidth (), trimHeight = trimHeight (); @@ -913,6 +913,12 @@ boolean isUndecorated () { (style & (SWT.NO_TRIM | SWT.ON_TOP)) != 0; } +/** + * Determines whether a Shell has both SWT.RESIZE and SWT.ON_TOP set without SWT.NO_TRIM. + * + * @return true if this Shell has both SWT.RESIZE and SWT.ON_TOP set without + * SWT.NO_TRIM, false otherwise. + */ boolean isCustomResize () { return (style & SWT.NO_TRIM) == 0 && (style & (SWT.RESIZE | SWT.ON_TOP)) == (SWT.RESIZE | SWT.ON_TOP); } @@ -1180,7 +1186,7 @@ Point getSizeInPixels () { int width = allocation.width; int height = allocation.height; int border = 0; - if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) { + if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0 || isCustomResize()) { border = GTK.gtk_container_get_border_width (shellHandle); } return new Point (width + trimWidth () + 2*border, height + trimHeight () + 2*border); @@ -2595,6 +2601,9 @@ boolean traverseEscape () { int trimHeight () { if ((style & SWT.NO_TRIM) != 0) return 0; if (fullScreen) return 0; + // Shells with both ON_TOP and RESIZE set only use border, not trim. + // See bug 319612. + if (isCustomResize()) return 0; boolean hasTitle = false, hasResize = false, hasBorder = false; hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0; hasResize = (style & SWT.RESIZE) != 0; @@ -2612,6 +2621,9 @@ int trimHeight () { int trimWidth () { if ((style & SWT.NO_TRIM) != 0) return 0; if (fullScreen) return 0; + // Shells with both ON_TOP and RESIZE set only use border, not trim. + // See bug 319612. + if (isCustomResize()) return 0; boolean hasTitle = false, hasResize = false, hasBorder = false; hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0; hasResize = (style & SWT.RESIZE) != 0; @@ -2780,7 +2792,7 @@ Rectangle getBoundsInPixels () { int width = allocation.width; int height = allocation.height; int border = 0; - if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) { + if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0 || isCustomResize()) { border = GTK.gtk_container_get_border_width (shellHandle); } return new Rectangle (x [0], y [0], width + trimWidth () + 2*border, height + trimHeight () + 2*border); |