Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-08-01 12:35:04 -0400
committerAlexander Kurtakov2018-08-04 09:12:32 -0400
commitdd3409ccc7c794b80af28d85c1c8e3d4d06b06b3 (patch)
tree872b330a90fba58fa0a23f4cb2e3ddad3d80c046
parentfd1e6ebd529d85760cfcdb5900f01902cd70eb4b (diff)
downloadeclipse.platform.swt-dd3409ccc7c794b80af28d85c1c8e3d4d06b06b3.tar.gz
eclipse.platform.swt-dd3409ccc7c794b80af28d85c1c8e3d4d06b06b3.tar.xz
eclipse.platform.swt-dd3409ccc7c794b80af28d85c1c8e3d4d06b06b3.zip
Bug 532941 - [Wayland] Error output about "a temporary window without
parent" 1) Attached snippet was broken on GTK3 with both x11 and Wayland. The column width is 0 and the table appears as a thin line. See bug 509503. This was fixed by always showing the table before getting preferred size on GTK3. 2) The warnings on Wayland occurs due to having a popup window without a parent. Shells with SWT.ON_TOP style was always created as a GTK_WINDOW_POPUP, this causes issues when the shell has no parent on Wayland due to lack of global coordinates. The fix is to never create a popup window without a parent. 3) Fixed the issue with the open editor dialog (CTRL+E) having a title bar above, by preventing decorations for shells without SHELL_TRIM style set. Tested with attached snippet and open editor (Ctrl + E) in child Eclipse with GTK3.22 on X11 and Wayland. Change-Id: I6d33c2e9bb00a55f84a79303f7326d0c8cd0a3ec Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java2
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug532941_WaylandWindowNoParent.java86
7 files changed, 125 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 66cb86aa46..7a4c8b4173 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -14950,6 +14950,16 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1window_1set_1icon_1list)
}
#endif
+#ifndef NO__1gtk_1window_1set_1keep_1above
+JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1window_1set_1keep_1above)
+ (JNIEnv *env, jclass that, jintLong arg0, jboolean arg1)
+{
+ GTK_NATIVE_ENTER(env, that, _1gtk_1window_1set_1keep_1above_FUNC);
+ gtk_window_set_keep_above((GtkWindow *)arg0, (gboolean)arg1);
+ GTK_NATIVE_EXIT(env, that, _1gtk_1window_1set_1keep_1above_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1window_1set_1modal
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1window_1set_1modal)
(JNIEnv *env, jclass that, jintLong arg0, jboolean arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 201a87c792..2e3901d11a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -1185,6 +1185,7 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1window_1set_1destroy_1with_1parent",
"_1gtk_1window_1set_1geometry_1hints",
"_1gtk_1window_1set_1icon_1list",
+ "_1gtk_1window_1set_1keep_1above",
"_1gtk_1window_1set_1modal",
"_1gtk_1window_1set_1opacity",
"_1gtk_1window_1set_1resizable",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index a6970170dc..21df733edb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -1183,6 +1183,7 @@ typedef enum {
_1gtk_1window_1set_1destroy_1with_1parent_FUNC,
_1gtk_1window_1set_1geometry_1hints_FUNC,
_1gtk_1window_1set_1icon_1list_FUNC,
+ _1gtk_1window_1set_1keep_1above_FUNC,
_1gtk_1window_1set_1modal_FUNC,
_1gtk_1window_1set_1opacity_FUNC,
_1gtk_1window_1set_1resizable_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index cf1c804177..03543415b0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -9803,6 +9803,19 @@ public class GTK extends OS {
}
/**
* @param window cast=(GtkWindow *)
+ * @param setting cast=(gboolean)
+ */
+ public static final native void _gtk_window_set_keep_above(long /*int*/ window, boolean setting);
+ public static final void gtk_window_set_keep_above(long /*int*/ window, boolean setting) {
+ lock.lock();
+ try {
+ _gtk_window_set_keep_above(window, setting);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @param window cast=(GtkWindow *)
* @param modal cast=(gboolean)
*/
public static final native void _gtk_window_set_modal(long /*int*/ window, boolean modal);
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 d2710b6031..64eb735dbf 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
@@ -414,7 +414,7 @@ public static Shell internal_new (Display display, long /*int*/ handle) {
static int checkStyle (Shell parent, int style) {
style = Decorations.checkStyle (style);
style &= ~SWT.TRANSPARENT;
- if ((style & SWT.ON_TOP) != 0) style &= ~(SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX);
+ if (parent != null && (style & SWT.ON_TOP) != 0) style &= ~(SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX);
int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
if ((style & SWT.SHEET) != 0) {
style &= ~SWT.SHEET;
@@ -704,7 +704,7 @@ void createHandle (int index) {
if (shellHandle == 0) {
if (handle == 0) {
int type = GTK.GTK_WINDOW_TOPLEVEL;
- if ((style & SWT.ON_TOP) != 0) type = GTK.GTK_WINDOW_POPUP;
+ if (parent != null && (style & SWT.ON_TOP) != 0) type = GTK.GTK_WINDOW_POPUP;
shellHandle = GTK.gtk_window_new (type);
} else {
shellHandle = GTK.gtk_plug_new (handle);
@@ -742,6 +742,8 @@ void createHandle (int index) {
// if (!isUndecorated ()) {
// OS.gtk_window_set_type_hint (shellHandle, OS.GDK_WINDOW_TYPE_HINT_DIALOG);
// }
+ } else {
+ if ((style & SWT.ON_TOP) != 0) GTK.gtk_window_set_keep_above(shellHandle, true);
}
/*
* Feature in GTK. The window size must be set when the window
@@ -770,7 +772,15 @@ void createHandle (int index) {
if ((style & SWT.TOOL) != 0) {
GTK.gtk_window_set_type_hint(shellHandle, GDK.GDK_WINDOW_TYPE_HINT_UTILITY);
}
- if ((style & SWT.NO_TRIM) != 0 ) {
+ if ((style & SWT.NO_TRIM) != 0) {
+ GTK.gtk_window_set_decorated(shellHandle, false);
+ }
+ /*
+ * On Wayland, shells with no SHELL_TRIM style specified have decorations by default.
+ * This fixes the issue that the open editor dialog (Ctrl+E) for Eclipse on Wayland
+ * has a tile bar on top.
+ */
+ if (!OS.isX11() && (style & SWT.SHELL_TRIM) == 0) {
GTK.gtk_window_set_decorated(shellHandle, false);
}
if (isCustomResize ()) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index b4ee6d0b47..f8b9fa700a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
@@ -441,7 +441,7 @@ public void pack () {
int width = 0;
if (buttonHandle != 0) {
GtkRequisition requisition = new GtkRequisition ();
- if (parent.getHeaderVisible() && GTK.GTK_VERSION >= OS.VERSION (3, 8, 0) && !GTK.gtk_widget_get_visible(buttonHandle)) {
+ if (GTK.GTK3) {
GTK.gtk_widget_show(buttonHandle);
gtk_widget_get_preferred_size (buttonHandle, requisition);
GTK.gtk_widget_hide(buttonHandle);
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug532941_WaylandWindowNoParent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug532941_WaylandWindowNoParent.java
new file mode 100644
index 0000000000..2ce1a71fd4
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug532941_WaylandWindowNoParent.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thomas Singer - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class Bug532941_WaylandWindowNoParent {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display, SWT.NO_FOCUS | SWT.ON_TOP);
+ shell.setLayout(new FillLayout());
+
+ final Table table = new Table(shell, SWT.VIRTUAL | SWT.V_SCROLL);
+
+ final TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
+ tableColumn.setText("Column");
+
+ final Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.MeasureItem) {
+ final Point size = event.gc.stringExtent(getText(event));
+ event.width = size.x;
+ event.height = size.y;
+ } else if (event.type == SWT.PaintItem) {
+ event.gc.drawString(getText(event), event.x, event.y);
+ } else if (event.type == SWT.SetData) {
+ event.item.setData("Row " + event.index);
+ } else if (event.type == SWT.MouseDown) {
+ if (event.button == 3) {
+ shell.dispose();
+ }
+ }
+ }
+
+ private String getText(Event event) {
+ return String.valueOf(event.item.getData());
+ }
+ };
+ table.addListener(SWT.SetData, listener);
+ table.addListener(SWT.MeasureItem, listener);
+ table.addListener(SWT.PaintItem, listener);
+ table.addListener(SWT.MouseDown, listener);
+ table.setItemCount(20);
+ table.clearAll();
+
+ shell.layout(true, false);
+
+ tableColumn.pack();
+ final int width = tableColumn.getWidth();
+ System.out.println("column width = " + width);
+
+ final int max = Math.min(10, table.getItemCount());
+ final Rectangle lastRowBounds = table.getItem(max - 1).getBounds();
+ final Rectangle rectangle = table.computeTrim(0, 0, width, lastRowBounds.y + lastRowBounds.height);
+
+ final Rectangle shellBounds = shell.computeTrim(0, 0, rectangle.width, rectangle.height);
+ shell.setSize(shellBounds.width, shellBounds.height);
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+} \ No newline at end of file

Back to the top