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 6.9
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>
This commit is contained in:
Shawn Rutledge 2025-04-29 18:27:33 +02:00
parent d1e030f6f5
commit b01fe1390c

View File

@ -2830,6 +2830,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
}