Bug 578178

Summary: SWT.GESTURE_END event is not sent due to wrong detection logic in Control.gestureEndProc
Product: [Eclipse Project] Platform Reporter: Simon Haegler <shaegler>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov
Version: 4.16   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Simon Haegler CLA 2022-01-12 04:34:59 EST
We have a GLCanvas which is receiving a GESTURE_BEGIN event for single clicks, but never a GESTURE_END. This prevents us from correctly handling mouse cursor switching and similar.

(Credit for the following investigation goes to my colleague Jonathan Meier.)

Gesture event support was introduced in Eclipse Bug 482018 [1] with commit [2]. We can see that GTK.gtk_gesture_is_recognized is checked in Control.gestureEndProc [3] where the SWT.GESTURE_END event should be created and sent. However, the documentation of Gtk.Gesture [4] states

A recognized gesture will then emit the following signals: - GtkGesture::begin when the gesture is recognized. - A number of GtkGesture::update, whenever an input event is processed. - GtkGesture::end when the gesture is no longer recognized.

So according to the documentation, GTK.gtk_gesture_is_recognized can never be true in Control.gestureEndProc and the gesture end event is probably inadvertently always filtered. Finally in the commit message of the commit introducing gesture support [2], the author mentions testing his changes with Snippet353 and indeed, in Snippet353.java [5] we see that SWT.GESTURE_END is always ignored which is probably the reason for the problem remaining undetected to date.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=482018
[2] https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/bundles/org.eclipse.swt/Eclipse%20SWT/gtk/org/eclipse/swt/widgets/Control.java?id=792560288388dee83bbcfaf3e4dcbee3b61c8044
[3] https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT/gtk/org/eclipse/swt/widgets/Control.java?h=R4_16#n5581
[4] https://docs.gtk.org/gtk3/class.Gesture.html
[5] https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet353.java?h=R4_16#n70
Comment 1 Alexander Kurtakov CLA 2022-01-12 04:39:08 EST
As you have done most of the investigation - do you think you can come up with patch fixing it and contribute it via Gerrit?