Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Pun2017-04-27 13:32:09 +0000
committerIan Pun2017-05-09 15:24:56 +0000
commiteb5d80847e4b2f685a6a5ff5ddc31f155062673a (patch)
treea85b294ba0ff5ff307f89f5050bf411168974d33
parent522e51fc512bad24a2056f31b81ba8c3793c0a54 (diff)
downloadeclipse.platform.swt-eb5d80847e4b2f685a6a5ff5ddc31f155062673a.tar.gz
eclipse.platform.swt-eb5d80847e4b2f685a6a5ff5ddc31f155062673a.tar.xz
eclipse.platform.swt-eb5d80847e4b2f685a6a5ff5ddc31f155062673a.zip
Bug 514483 - [wayland] Launchbar filter closes when clickedI20170509-1300
GetCursorLocation() was returning wrong coordinates. In Wayland applications do not share a global coordinate, instead it is relative to the parent window. The position of the cursor was returning relative to the popup window and not of the parent window, causing the LaunchBar logic to think that we are clicking outside of the popup window, thus closing it. Fixed by using the relative position as an offset and adding it to the position of the popup window, which will return the correct coordinates. Testing this can be done through snippetA in https://bugs.eclipse.org/bugs/show_bug.cgi?id=514483 . Tested with Junits on Wayland with no additional failures/errors. Change-Id: I9bfb2052e59de38a93f75cc624759b41885ae2a6 Signed-off-by: Ian Pun <ipun@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index c9cef5d410..33ab2727e9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -1612,6 +1612,26 @@ Point getCursorLocationInPixels () {
checkDevice ();
int [] x = new int [1], y = new int [1];
gdk_window_get_device_position (0, x, y, null);
+ /*
+ * Wayland feature: There is no global x/y coordinates in Wayland for security measures, so they
+ * all return relative coordinates dependant to the root window. If there is a popup window (type SWT.ON_TOP),
+ * the return position is relative to the new popup window and not relative to the parent if its
+ * active. Using that as an offset and adding all parent shell relative coordinates will give the
+ * user the correct mouse position in Wayland. This only supports popups that are type
+ * SWT.ON_TOP as any other type of window is not tied to the parent window through
+ * a subsurface. There is currently no support for global coordinates
+ * in Wayland. See Bug 514483.
+ */
+ if (!OS.isX11() && activeShell != null) {
+ Shell tempShell = activeShell;
+ int [] offsetX = new int [1], offsetY = new int [1];
+ while (tempShell.getParent() != null) {
+ OS.gtk_window_get_position(tempShell.shellHandle, offsetX, offsetY);
+ x[0]+= offsetX[0];
+ y[0]+= offsetY[0];
+ tempShell = tempShell.getParent().getShell();
+ }
+ }
return new Point (x [0], y [0]);
}

Back to the top