Windows QPA: don't override user-removed margins
When calculating margins, added a check to see if the window rect and the client rect are the same size. If they are, we return early, to avoid overwriting user-defined specific margins. Fixes: QTBUG-117704 Pick-to: 6.6 6.5 Change-Id: I9947feab4cb900293fb6be6cf09c56268f38d64a Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 03a4164206d64151da7e0b0f850063e501bdea57) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
01d12a2d98
commit
d2881ae09b
@ -2775,11 +2775,6 @@ void QWindowsWindow::calculateFullFrameMargins()
|
||||
{
|
||||
if (m_data.flags & Qt::FramelessWindowHint)
|
||||
return;
|
||||
// Normally obtained from WM_NCCALCSIZE. This calculation only works
|
||||
// when no native menu is present.
|
||||
const auto systemMargins = testFlag(DisableNonClientScaling)
|
||||
? QWindowsGeometryHint::frameOnPrimaryScreen(window(), m_data.hwnd)
|
||||
: frameMargins_sys();
|
||||
|
||||
// QTBUG-113736: systemMargins depends on AdjustWindowRectExForDpi. This doesn't take into
|
||||
// account possible external modifications to the titlebar, as with ExtendsContentIntoTitleBar()
|
||||
@ -2793,6 +2788,20 @@ void QWindowsWindow::calculateFullFrameMargins()
|
||||
RECT clientRect{};
|
||||
GetWindowRect(handle(), &windowRect);
|
||||
GetClientRect(handle(), &clientRect);
|
||||
|
||||
// QTBUG-117704 It is also possible that the user has manually removed the frame (for example
|
||||
// by handling WM_NCCALCSIZE). If that is the case, i.e., the client area and the window area
|
||||
// have identical sizes, we don't want to override the user-defined margins.
|
||||
|
||||
if (qrectFromRECT(windowRect).size() == qrectFromRECT(clientRect).size())
|
||||
return;
|
||||
|
||||
// Normally obtained from WM_NCCALCSIZE. This calculation only works
|
||||
// when no native menu is present.
|
||||
const auto systemMargins = testFlag(DisableNonClientScaling)
|
||||
? QWindowsGeometryHint::frameOnPrimaryScreen(window(), m_data.hwnd)
|
||||
: frameMargins_sys();
|
||||
|
||||
const int yDiff = (windowRect.bottom - windowRect.top) - (clientRect.bottom - clientRect.top);
|
||||
const bool typicalFrame = (systemMargins.left() == systemMargins.right())
|
||||
&& (systemMargins.right() == systemMargins.bottom());
|
||||
|
Loading…
x
Reference in New Issue
Block a user