diff options
author | Volker Hilsheimer <[email protected]> | 2021-12-22 11:08:53 +0100 |
---|---|---|
committer | Volker Hilsheimer <[email protected]> | 2021-12-22 14:09:56 +0100 |
commit | 0462d24dcd851222d4ac73e7af38d785c6a32cfd (patch) | |
tree | c91e77dcf861d81fec87f5e2e616f3f83a9f2bc9 /src | |
parent | 58058794b1379f153d28d844d5220298f21bcf96 (diff) |
Deliver context menu event with correct coordinates to widgets in popups
If a popup is open, Qt delivers events to the popup child under the
mouse, so we need to correctly translate the local position of the
context menu event to that child's coordate system.
This is already done correctly for regular mouse events, so use the same
logic here.
Fixes: QTBUG-99371
Pick-to: 6.2 6.3 5.15
Change-Id: Ief24c755e76d4d1aa2304b06662ed26ae309f684
Reviewed-by: Tor Arne Vestbø <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index c750d9f730c..14a2655e35b 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -617,7 +617,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) receiver = qt_button_down; else if (popupChild) receiver = popupChild; - QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPosition().toPoint(), event->modifiers()); + const QPoint localPos = receiver->mapFromGlobal(event->globalPosition().toPoint()); + QContextMenuEvent e(QContextMenuEvent::Mouse, localPos, event->globalPosition().toPoint(), event->modifiers()); QApplication::forwardEvent(receiver, &e, event); } #else |