From 74d865a3e3d46617d21999d91fb31cd8dc04dcc7 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 16 Nov 2020 18:13:52 +0800 Subject: [PATCH] Fix a multi-screen bug Before this patch, the maximum size of a frameless window will be limited to the primary screen's size if the user doesn't set a maximum window size explicitly. It works fine on single screen cases, however, if you have multiple screens and when you are trying to resize the window to some size bigger than the primary screen, such as expand it from one screen to another, the window will refuse to continue resizing after it reaches the primary screen's size. The solution is simple and straightforward: if the user doesn't set the maximum window size explicitly, just don't set the maximum size to let it can be resized without any limitations. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- winnativeeventfilter.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 5294309..900cd5d 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -1983,17 +1983,14 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, mmi->ptMaxPosition.x = rcMonitorArea.left; mmi->ptMaxPosition.y = rcMonitorArea.top; } - if (data->maximumSize.isEmpty()) { - mmi->ptMaxSize.x = qAbs(rcWorkArea.right - rcWorkArea.left); - mmi->ptMaxSize.y = qAbs(rcWorkArea.bottom - rcWorkArea.top); - } else { + if (!data->maximumSize.isEmpty()) { mmi->ptMaxSize.x = qRound(GetDevicePixelRatioForWindow(msg->hwnd) * data->maximumSize.width()); mmi->ptMaxSize.y = qRound(GetDevicePixelRatioForWindow(msg->hwnd) * data->maximumSize.height()); + mmi->ptMaxTrackSize.x = mmi->ptMaxSize.x; + mmi->ptMaxTrackSize.y = mmi->ptMaxSize.y; } - mmi->ptMaxTrackSize.x = mmi->ptMaxSize.x; - mmi->ptMaxTrackSize.y = mmi->ptMaxSize.y; if (!data->minimumSize.isEmpty()) { mmi->ptMinTrackSize.x = qRound(GetDevicePixelRatioForWindow(msg->hwnd) * data->minimumSize.width());