From e2c98afd5a9d475f04048a94afad321c505d8729 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 23 May 2016 01:56:08 +0200 Subject: [PATCH] Sync with X server before simulating mouse clicks Adding a call to XSync() to wxUIActionSimulatorX11Impl seems to fix the problems with the focus snapping back to the control having it previously after simulating a mouse click and changing the focus afterwards using wxWindow::SetFocus(), as the uiaction sample did. Admittedly, it's not really clear why does doing it help, but at the very leasy this XSync() call shouldn't do any harm. --- src/unix/uiactionx11.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unix/uiactionx11.cpp b/src/unix/uiactionx11.cpp index e8b47f7579..50c525b333 100644 --- a/src/unix/uiactionx11.cpp +++ b/src/unix/uiactionx11.cpp @@ -106,6 +106,10 @@ bool wxUIActionSimulatorX11Impl::SendButtonEvent(int button, bool isDown) return false; } + // Ensure that the event is received by the correct window by processing + // all pending events, notably mouse moves. + XSync(m_display, False /* don't discard */); + return DoX11Button(xbutton, isDown); }