Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-04-12 19:14:17 +0000
committerEric Williams2018-04-13 16:15:53 +0000
commitf894bab36d1d8d6bf87a55af6e74c42eb00fb145 (patch)
treea1ac488c1f2ab036c7d273e840da0251be529a88
parent932adc1c8e531bf57e4948d87e5db9ae3f4c9a54 (diff)
downloadeclipse.platform.swt-f894bab36d1d8d6bf87a55af6e74c42eb00fb145.tar.gz
eclipse.platform.swt-f894bab36d1d8d6bf87a55af6e74c42eb00fb145.tar.xz
eclipse.platform.swt-f894bab36d1d8d6bf87a55af6e74c42eb00fb145.zip
Bug 529126: [Wayland][GTK3] Tree does not notify SWT.MouseDown listeners
Flush the DragDetection queue so that MouseDown events are still sent if MouseUp isn't hooked. This patch adapts some of the DnD caching logic implemented by bug 510446. Tested on Wayland with GTK3.22. The bug reproducer snippet works as expected and the IDE functions normally. No AllNonBrowser JUnit test failures occur. Change-Id: Ida37543ae748a2a0d91eee192ae3bce34b2cbb0d Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java32
1 files changed, 30 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 4fad46995e..61a9d0d311 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -4421,7 +4421,34 @@ boolean sendMouseEvent (int type, int button, int time, double x, double y, bool
* false - event sending canceled by user.
*/
boolean sendMouseEvent (int type, int button, int count, int detail, boolean send, int time, double x, double y, boolean is_hint, int state) {
- if (!hooks (type) && !filters (type)) return true;
+ if (!hooks (type) && !filters (type)) {
+ /*
+ * On Wayland, MouseDown events are cached for DnD purposes, but
+ * unfortunately this breaks simple cases with a single MouseDown
+ * listener. The MouseDown event is cached but never sent, as MouseUp
+ * isn't hooked and thus the logic to send cached events is never run.
+ *
+ * The solution is to check for MouseUp events even if MouseUp isn't
+ * hooked. We can check the queue and flush it by sending the MouseDown
+ * event, similar to the way the caching logic does it when receiving a
+ * MouseMove event. See bug 529126.
+ */
+ if (!OS.isX11() && dragDetectionQueue != null) {
+ /*
+ * The first event in the queue will always be a MouseDown, as
+ * the queue is only ever created if a MouseDown event is being cached.
+ * Thus, if the queue only has one element, it is guaranteed to be a
+ * MouseDown event. More than 1 element implies MouseMove: let the caching
+ * logic handle this case.
+ */
+ if (type == SWT.MouseUp && dragDetectionQueue.size() == 1) {
+ Event mouseDownEvent = dragDetectionQueue.getFirst();
+ dragDetectionQueue = null;
+ sendOrPost(SWT.MouseDown, mouseDownEvent);
+ }
+ }
+ return true;
+ }
Event event = new Event ();
event.time = time;
event.button = button;
@@ -4479,8 +4506,9 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
mouseDownEvent.data = Boolean.valueOf(true); // force send MouseDown to avoid subsequent MouseMove before MouseDown.
dragDetectionQueue = null;
sendOrPost(SWT.MouseDown, mouseDownEvent);
- } else
+ } else {
dragDetectionQueue.add(event);
+ }
break;
case SWT.MouseUp:
// Case where mouse up was released before DnD threshold was hit.

Back to the top