From 8ed116bdc6461523dd757158c95086621978797b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 17 Oct 2019 22:05:17 +0200 Subject: [PATCH] Use a hack to work around mouse click emulation bug with GTK 3 Somehow, mouse release events generated immediately after the mouse press ones are sometimes (not always, but often enough to reliably prevent the test suite from passing) simply lost, i.e. not received by the GTK event loop. The only workaround seems to be to introduce an artificial delay, which does avoid the problem, at the price of making the tests run longer and, worse, not really solving the underlying problem, whatever it is. But it's still better than nothing. --- src/unix/uiactionx11.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/unix/uiactionx11.cpp b/src/unix/uiactionx11.cpp index 8d72835868..5233e6d64f 100644 --- a/src/unix/uiactionx11.cpp +++ b/src/unix/uiactionx11.cpp @@ -28,6 +28,8 @@ #include "wx/unix/utilsx11.h" #ifdef __WXGTK3__ +#include "wx/utils.h" + #include "wx/gtk/private/wrapgtk.h" GtkWidget* wxGetTopLevelGTK(); #endif @@ -333,6 +335,13 @@ bool wxUIActionSimulatorX11Impl::MouseMove(long x, long y) bool wxUIActionSimulatorX11Impl::MouseUp(int button) { +#ifdef __WXGTK3__ + // This is a horrible hack, but some mouse click events are just lost + // without any apparent reason when using GTK 3 without this, i.e. they + // simply never reach GTK in some runs of the tests. + wxMilliSleep(10); +#endif + return SendButtonEvent(button, false); }