diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-12-22 11:08:53 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-12-22 14:33:05 +0000 |
commit | d0b5adb3b28bf5b9d94ef46cecf402994e7c5b38 (patch) | |
tree | 1d2e60658c0e5c32829e746af9ee8452c889b92a /src | |
parent | a143ccda112f4eb3ee461f2b62a5581a11794b16 (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
Change-Id: Ief24c755e76d4d1aa2304b06662ed26ae309f684
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 0462d24dcd851222d4ac73e7af38d785c6a32cfd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
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 79038fa493..1501407a42 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -629,7 +629,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 |