summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothée Keller <[email protected]>2023-10-04 10:59:45 +0200
committerQt Cherry-pick Bot <[email protected]>2024-03-12 10:41:10 +0000
commit0eb11bcee06de75ac2464f2937301ee4a3f7b72f (patch)
treeaae1d431b11e4d6cdff56e8bed23e3d21f81a618
parent67f497ed9736bd63f7d053978fc31482bd965559 (diff)
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 Change-Id: I9947feab4cb900293fb6be6cf09c56268f38d64a Reviewed-by: Oliver Wolff <[email protected]> (cherry picked from commit 03a4164206d64151da7e0b0f850063e501bdea57) Reviewed-by: Qt Cherry-pick Bot <[email protected]> (cherry picked from commit d2881ae09b0a5e06b9c223e51a61a99655b4036f) (cherry picked from commit 0056998ba8def608c00e544765484407b186b3ff)
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index b21ef874f88..b53eb9cf6e1 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2780,11 +2780,6 @@ void QWindowsWindow::calculateFullFrameMargins()
{
if (shouldOmitFrameAdjustment(m_data.flags, m_data.hwnd))
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()
@@ -2798,6 +2793,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());