summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbwindow.h
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2023-11-27 16:33:12 +0100
committerAxel Spoerl <axel.spoerl@qt.io>2023-12-06 11:58:17 +0100
commit2f6fe3a26843ff68c5d3f9af0a2fc3cce6caac22 (patch)
treeb8b8c5fb7c0f97c9a98edd858a28356a6ff27742 /src/plugins/platforms/xcb/qxcbwindow.h
parent3a57885c3766d4ae203650d60881988c374e4148 (diff)
QXcbWindow: protect access to m_mapped with a QMutex
QXcbWindow::requestActivateWindow() is called from the main thread, while handleMapNotifyEvent() is called from the XCB event thread. In a data race, handleMapNotifyEvent sets m_mapped to true, before requestActivateWindow() checks if it is false and sets m_deferredActivation to true. If that happens, a window activation is skipped until the next window systems event is processed. This is harmless in a normal application environment, where each mouse move causes window systems events to be processed. In an autotest environment, it causes flakiness, because an expected window activation may or may not happen. As a workaround, QApplicationPrivate::setActiveWindow() is frequently called after QWidget::activateWindow() or QWindow::requestActivate(), to set the active window on application level. In essence, this is setting expected outcome of a skipped deferred activation by force. This patch protects access to m_mapped and m_deferredActivation with a QMutex in both methods. That prevents the data race and ensures all deferred activations processed. Calling QApplicationPrivate::setActiveWindow() after activation on window/widget level becomes redundant. Task-number: QTBUG-119287 Pick-to: 6.6 6.5 Change-Id: I2eee69292afe0ef6381880a10d4e8483c2c7cbfa Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbwindow.h')
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index a04b4408a4..415dff09ba 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -222,6 +222,7 @@ protected:
Qt::WindowStates m_windowState = Qt::WindowNoState;
+ QMutex m_mappedMutex;
bool m_mapped = false;
bool m_transparent = false;
bool m_deferredActivation = false;