From b4a27c059ba6216500219045ab49401d69284256 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao Date: Fri, 7 Apr 2023 16:56:58 +0800 Subject: [PATCH] fix system menu wrong position Signed-off-by: Yuhang Zhao --- src/quick/quickstandardtitlebar.cpp | 5 +++-- src/widgets/standardtitlebar.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/quick/quickstandardtitlebar.cpp b/src/quick/quickstandardtitlebar.cpp index 1b5621e0..d99fa48d 100644 --- a/src/quick/quickstandardtitlebar.cpp +++ b/src/quick/quickstandardtitlebar.cpp @@ -421,10 +421,11 @@ bool QuickStandardTitleBar::mouseEventHandler(QMouseEvent *event) return; } FramelessQuickHelper::get(this)->showSystemMenu([this, button, &scenePos]() -> QPoint { + QPoint pos = scenePos; if (button == Qt::LeftButton) { - return {0, int(std::round(height()))}; + pos = {0, int(std::round(height()))}; } - return scenePos; + return mapToGlobal(pos).toPoint(); }()); }); // Don't eat this event, we have not handled it yet. diff --git a/src/widgets/standardtitlebar.cpp b/src/widgets/standardtitlebar.cpp index 4fcd4d16..52580587 100644 --- a/src/widgets/standardtitlebar.cpp +++ b/src/widgets/standardtitlebar.cpp @@ -343,11 +343,12 @@ bool StandardTitleBarPrivate::mouseEventHandler(QMouseEvent *event) return; } // Please refer to the comments in StandardTitleBarPrivate::setWindowIconVisible(). - FramelessWidgetsHelper::get(m_window)->showSystemMenu([button, q, &scenePos]() -> QPoint { + FramelessWidgetsHelper::get(m_window)->showSystemMenu([button, q, &scenePos, this]() -> QPoint { + QPoint pos = scenePos; if (button == Qt::LeftButton) { - return {0, q->height()}; + pos = {0, q->height()}; } - return scenePos; + return m_window->mapToGlobal(pos); }()); }); // Don't eat this event, we have not handled it yet.