From 595647cb6c5f223a1ad430a026f16f18fdb10cd2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 29 Apr 2025 18:27:33 +0200 Subject: [PATCH] maybeSynthesizeContextMenuEvent: accept mouse event if CME accepted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to 84a5f50c7766c99f62b22bb4388137e0aa8dd13d QWidgetWindow::handleMouseEvent() did its own synthesis of QContextMenuEvents. Then we moved it to QWindowPrivate::maybeSynthesizeContextMenuEvent() and didn't preserve the code to accept the QMouseEvent if the QContextMenuEvent was accepted. It turns out that the WASM platform depends on checking whether the QPA mouse press event was accepted: if not, it closes all popups, including any context menu that was just opened by a right mouse press. Fixes: QTBUG-136241 Change-Id: Ibe01763a6af19d65629dc77eb61ffc1af581efbe Pick-to: 6.8 Reviewed-by: Even Oscar Andersen Reviewed-by: Tor Arne Vestbø Reviewed-by: Mitch Curtis (cherry picked from commit b01fe1390cd22165104aba5eb49dae90c0b91618) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 6a3bb83495b..0417df64da7 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2810,6 +2810,8 @@ void QWindowPrivate::maybeSynthesizeContextMenuEvent(QMouseEvent *event) << (event->isAccepted() ? "ACCEPTED (legacy behavior)" : "ignored") << event->type() << ":" << &e; QCoreApplication::forwardEvent(q_func(), &e, event); + if (e.isAccepted()) + event->accept(); } #endif }