Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-12-06 16:04:11 -0500
committerEric Williams2018-12-11 12:01:32 -0500
commit390d1cb644b734e2a185af54300b7b78352adca2 (patch)
tree23dccf0a5670e253822116fe9374f7c9d2d6f917
parent0e7557472c35a7863593f5db14fabdcafdaab23e (diff)
downloadeclipse.platform.swt-390d1cb644b734e2a185af54300b7b78352adca2.tar.gz
eclipse.platform.swt-390d1cb644b734e2a185af54300b7b78352adca2.tar.xz
eclipse.platform.swt-390d1cb644b734e2a185af54300b7b78352adca2.zip
Bug 532074 - [Wayland] Arrow menu from fast view pops up in wrong
location setLocation method is limited on Wayland since we cannot use gdk_popup_at_rect if GdkWindow of the shell is not mapped. When the Problems View is a fast view on Eclipse start, the drop down menu takes PartRenderingEngine's limbo shell (see PartRenderingEngine#safeCreateGui) as the parent shell which is off the screen. The limbo shell's GdkWindow cannot be used on Wayland to popup the menu at a relative location. In this case, we open the menu at the pointer to avoid it being positioned in the wrong location. Change-Id: Ifa120a0e68e0d012b09c1f4806dc959bb447b8f2 Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 155fa96f86..0de63b9c38 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -196,6 +196,24 @@ static int checkStyle (int style) {
return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
}
+/**
+ * Bug 532074: setLocation method is limited on Wayland since Wayland
+ * has no global coordinates and we cannot use gdk_popup_at_rect if GdkWindow of
+ * getShell is not mapped. In this case, we can only pop the menu at the pointer.
+ *
+ * This happens for example when Problems view is a fast view on Eclipse start,
+ * the drop down menu takes PartRenderingEngine's limbo shell
+ * (see PartRenderingEngine#safeCreateGui) which is off the screen.
+ *
+ * @return true iff the location of menu is set and can be used successfully
+ */
+boolean ableToSetLocation() {
+ if (!OS.isX11() && !getShell().getVisible()) {
+ return false;
+ }
+ return hasLocation;
+}
+
void _setVisible (boolean visible) {
if (visible == GTK.gtk_widget_get_mapped (handle)) return;
if (visible) {
@@ -235,7 +253,7 @@ void _setVisible (boolean visible) {
GTK.gtk_menu_popup (handle, 0, 0, address, data, 0, display.getLastEventTime ());
} else {
long /*int*/ eventPtr = 0;
- if (hasLocation) {
+ if (ableToSetLocation()) {
// Create the GdkEvent manually as we need to control
// certain fields like the event window
eventPtr = GDK.gdk_event_new(GDK.GDK_BUTTON_PRESS);
@@ -261,7 +279,7 @@ void _setVisible (boolean visible) {
rect.x = this.x - globalWindowOriginX[0];
rect.y = this.y - globalWindowOriginY[0];
} else {
- // On Wayland, get the relative GdkWindow from the parent shell.
+ // On Wayland, get the relative GdkWindow from the parent shell
event.window = OS.g_object_ref(GTK.gtk_widget_get_window (getShell().topHandle()));
OS.memmove (eventPtr, event, GdkEventButton.sizeof);
// Bug in GTK?: testing with SWT_MENU_LOCATION_DEBUGGING=1 shows final_rect.x and

Back to the top