Spurious gesture end events are generated whenever wxGTK receives a Gtk.Gesture::cancel signal.
GTK3 sometimes generates cancel signals even if no gesture is active, for example when a grab is started.
I have also observed GTK3 generating both a cancel and an end signal for a gesture, resulting in a duplicate wxWidgets GestureEnd event.
The cause of the problem is that wxGTK registers the same handler for both Gtk.Gesture::cancel and Gtk.Gesture::end, and doesn't check if a gesture is active before dispatching a wx event:
When a menu is opened by calling PopupMenu(), a spurious wxGestureEvent with IsGestureEnd() == true is dispatched in response to a Gtk.Gesture::cancel signal.
No gesture end events dispatched when gesture isn't active.
diff --git a/samples/event/gestures.cpp b/samples/event/gestures.cpp index e58227358a..ff5a1faee1 100644 --- a/samples/event/gestures.cpp +++ b/samples/event/gestures.cpp @@ -144,6 +144,12 @@ MyGestureFrame::MyGestureFrame() myPanel->Bind(wxEVT_LONG_PRESS, &MyGestureFrame::OnGesture, this); myPanel->Bind(wxEVT_PRESS_AND_TAP, &MyGestureFrame::OnGesture, this); + myPanel->Bind(wxEVT_CONTEXT_MENU, [myPanel](auto &) { + wxMenu menu; + menu.Append(wxID_ANY, "Menu Item"); + myPanel->PopupMenu(&menu); + }); + Bind(wxEVT_CLOSE_WINDOW, &MyGestureFrame::OnQuit, this); }
event sample with the above patch14:29:33: Zoom gesture performed with zoom center at (0, 0) and zoom Factor = 1.000000
14:29:33: Zoom gesture ended
14:29:33: Rotate gesture performed with rotation center at (0, 0) and cumulative rotation angle = 0.000000
14:29:33: Rotate gesture ended
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
It looks like this should be relatively simple to fix, but I have no way to test it, so any patches would be very welcome!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I think I can do something like adding gs_zoomGestureActive and gs_rotateGestureActive and check them before dispatching the event.
But before I do that, can I ask why these are all global?
// This is true when the gesture has just started (currently used for pan gesture only) static bool gs_gestureStart = false; // Last offset for the pan gesture, this is used to calculate deltas for pan gesture event static double gs_lastOffset = 0; // Last scale provided by GTK static gdouble gs_lastScale = 1.0; // This is used to set the angle when rotate gesture ends. static gdouble gs_lastAngle = 0; // Last Zoom/Rotate gesture point static wxPoint gs_lastGesturePoint;
It seems to me that sharing this state among all windows could cause problems, e.g. if I add gs_zoomGestureActive, then GTK cancelling a gesture in one window would set gs_zoomGestureActive to false, even though as I understand it a gesture in another window could still be active.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
This code was added back in 261b04b (Merge multi-touch gestures event branch, 2017-09-10) and I am not sure why it was done like this, but I guess it was the simplest solution and the original author thought that there could be only one gesture in progress at any time (which seems plausible but I'm not sure if this is actually true).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
which seems plausible but I'm not sure if this is actually true
I don't really know. In my limited testing I wasn't able to trigger multiple gestures at once, but I'm not sure if I can rule it out in crazy situations like using a touchscreen and a touchpad at the same time, or using weird Wayland compositors.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()