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>
This commit is contained in:
Yuhang Zhao 2020-11-16 18:13:52 +08:00
parent 8ca84fd435
commit 74d865a3e3
1 changed files with 3 additions and 6 deletions

View File

@ -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;
}
if (!data->minimumSize.isEmpty()) {
mmi->ptMinTrackSize.x = qRound(GetDevicePixelRatioForWindow(msg->hwnd)
* data->minimumSize.width());