From c9debd9583e4ebf863d4461906452f32fb6b9b5f Mon Sep 17 00:00:00 2001 From: brige Date: Mon, 17 Nov 2025 21:53:07 +0800 Subject: [PATCH] modify other screen max to move --- src/ui/FramelessDelegateWin.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/ui/FramelessDelegateWin.cpp b/src/ui/FramelessDelegateWin.cpp index e994ca7d..5bb7b1a2 100644 --- a/src/ui/FramelessDelegateWin.cpp +++ b/src/ui/FramelessDelegateWin.cpp @@ -162,24 +162,22 @@ bool FramelessDelegateWin::nativeEvent(const QByteArray & eventType, void* messa if (monitor && GetMonitorInfo(monitor, &mi)) { const RECT& work = mi.rcWork; const RECT& rcMon = mi.rcMonitor; - const int frameX = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER); - const int frameY = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER); + // Use monitor work area directly to avoid off-screen placement on multi-monitor setups + mmi->ptMaxPosition.x = 0; + mmi->ptMaxPosition.y = 0; + mmi->ptMaxSize.x = (work.right - work.left); + mmi->ptMaxSize.y = (work.bottom - work.top); - mmi->ptMaxPosition.x = work.left - frameX; - mmi->ptMaxPosition.y = work.top - frameY; - mmi->ptMaxSize.x = (work.right - work.left) + frameX * 2; - mmi->ptMaxSize.y = (work.bottom - work.top) + frameY * 2; - - mmi->ptMaxTrackSize.x = (rcMon.right - rcMon.left) + frameX * 2; - mmi->ptMaxTrackSize.y = (rcMon.bottom - rcMon.top) + frameY * 2; + mmi->ptMaxTrackSize.x = (rcMon.right - rcMon.left); + mmi->ptMaxTrackSize.y = (rcMon.bottom - rcMon.top); const QSize minSize = mainWidget_->minimumSize(); const double dpr = mainWidget_->devicePixelRatioF(); const int minWpx = static_cast(std::round(minSize.width() * dpr)); const int minHpx = static_cast(std::round(minSize.height() * dpr)); // Guard against zero/negative values - const int clampedMinW = std::max(1, minWpx) + frameX * 2; - const int clampedMinH = std::max(1, minHpx) + frameY * 2; + const int clampedMinW = std::max(1, minWpx); + const int clampedMinH = std::max(1, minHpx); mmi->ptMinTrackSize.x = clampedMinW; mmi->ptMinTrackSize.y = clampedMinH; } @@ -258,6 +256,7 @@ void FramelessDelegateWin::OnClose() { void FramelessDelegateWin::OnScreenChangeInternaal() { if (mainWidget_->internalWinId()) { + CheckMonitorChanged(); SetWindowPos(reinterpret_cast(mainWidget_->winId()), nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); }