fix system menu wrong position

Signed-off-by: Yuhang Zhao <zhaoyuhang@rankyee.com>
This commit is contained in:
Yuhang Zhao 2023-04-07 16:56:58 +08:00
parent b597d2c91a
commit b4a27c059b
2 changed files with 7 additions and 5 deletions

View File

@ -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.

View File

@ -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.