diff options
author | Xi Yan | 2018-10-09 17:24:27 +0000 |
---|---|---|
committer | Xi Yan | 2018-10-12 18:37:54 +0000 |
commit | de6e88927bc6145d9afed2fbb1848e81f7702b14 (patch) | |
tree | 5ed1bac780ec63ef28e0078a9045f3384e694806 | |
parent | 8abd3686d9521f473531c3d8b80ff687636263eb (diff) | |
download | eclipse.platform.swt-de6e88927bc6145d9afed2fbb1848e81f7702b14.tar.gz eclipse.platform.swt-de6e88927bc6145d9afed2fbb1848e81f7702b14.tar.xz eclipse.platform.swt-de6e88927bc6145d9afed2fbb1848e81f7702b14.zip |
Bug 535075 - [Wayland] application rendered with an offset relatively to
host window
On Wayland, calling gtk_widget_size_allocate with a relative position to
the GtkContainer causes window contents to be rendered outside of the
actual GtkWindow. The fix is to map container's coordinate relative to
the window's coordinate, and render the position according to the
relative coordinate.
Tested with child Eclipse Tip of the Day on Wayland (Bug 536153).
Change-Id: I93d26be94f57fcb7556f4fe683f41783d5ebcdbc
Signed-off-by: Xi Yan <xixiyan@redhat.com>
2 files changed, 56 insertions, 0 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 9440f240d5..2aad6d6eda 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 @@ -1010,6 +1010,18 @@ void forceResize (int width, int height) { GtkRequisition naturalSize = new GtkRequisition (); GTK.gtk_widget_get_preferred_size (vboxHandle, minimumSize, naturalSize); } + /* + * Bug 535075, 536153: On Wayland, we need to set the position of the GtkBox container + * relative to the shellHandle to prevent window contents rendered with offset. + */ + if (!OS.isX11()) { + int [] dest_x = new int[1]; + int [] dest_y = new int[1]; + GTK.gtk_widget_translate_coordinates(vboxHandle, shellHandle, 0, 0, dest_x, dest_y); + allocation.x += dest_x[0]; + allocation.y += dest_y[0]; + } + GTK.gtk_widget_size_allocate (vboxHandle, allocation); if ((style & SWT.MIRRORED) != 0) moveChildren (clientWidth); } diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug535075_WaylandOffset.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug535075_WaylandOffset.java new file mode 100644 index 0000000000..2c15a53dc5 --- /dev/null +++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug535075_WaylandOffset.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat and others. All rights reserved. + * The contents of this file are made available under the terms + * of the GNU Lesser General Public License (LGPL) Version 2.1 that + * accompanies this distribution (lgpl-v21.txt). The LGPL is also + * available at http://www.gnu.org/licenses/lgpl.html. If the version + * of the LGPL at http://www.gnu.org is different to the version of + * the LGPL accompanying this distribution and there is any conflict + * between the two license versions, the terms of the LGPL accompanying + * this distribution shall govern. + * + * Contributors: + * Red Hat - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.tests.gtk.snippets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class Bug535075_WaylandOffset { + + public static void main(String[] args) { + + Display display = new Display(); + Shell shell = new Shell(display); + shell.setLayout(new FillLayout()); + + Button b = new Button(shell, SWT.NONE); + b.setText("pushme"); + b.addListener(SWT.Selection, event -> { + shell.requestLayout(); + }); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + display.dispose(); + } + +} |