diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index 6f0680ac23a..21d15d4e78b 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include #include #include @@ -388,6 +390,10 @@ bool QWindowsSystemTrayIcon::winEvent(const MSG &message, long *result) // since hi-res coordinates are delivered in this case (Windows issue). // Default to primary screen with check to prevent a crash. const QPoint globalPos = QPoint(GET_X_LPARAM(message.wParam), GET_Y_LPARAM(message.wParam)); + // QTBUG-130832: QMenu relies on lastCursorPosition being up to date. When this code + // is called it still holds the last known mouse position inside a Qt window. Do a + // forced update of this position. + QGuiApplicationPrivate::lastCursorPosition = QCursor::pos().toPointF(); const auto &screenManager = QWindowsContext::instance()->screenManager(); const QPlatformScreen *screen = screenManager.screenAtDp(globalPos); if (!screen)