maybeSynthesizeContextMenuEvent: accept mouse event if CME accepted

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 <even.oscar.andersen@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit b01fe1390cd22165104aba5eb49dae90c0b91618)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Shawn Rutledge 2025-04-29 18:27:33 +02:00 committed by Qt Cherry-pick Bot
parent ee9ee08762
commit 595647cb6c

View File

@ -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
}