Windows QPA: Prevent restoreGeometry from showing hidden windows

When we use GetWindowPlacement, the showCmd parameter will NOT be
SW_HIDE, even if the window is hidden. To prevent showing a hidden window
with SetWindowPlacement, change showCmd if the window is currently hidden.

Amends 21e411687428d05655b8db2634466384fa35cc03

Fixes: QTBUG-120415
Change-Id: Ib7de369a6d1a530fdeb5ff930097ae06e25761f3
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Zhao Yuhang <yuhangzhao@deepin.org>
(cherry picked from commit 8a5fed6da41bcc29506d5b4e166a6e87e8fe9eb7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Timothée Keller 2024-01-09 13:21:24 +01:00 committed by Qt Cherry-pick Bot
parent e4f87f2045
commit 316946089d

View File

@ -2480,6 +2480,11 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state)
GetWindowPlacement(m_data.hwnd, &windowPlacement);
const RECT geometry = RECTfromQRect(m_data.restoreGeometry);
windowPlacement.rcNormalPosition = geometry;
// Even if the window is hidden, windowPlacement's showCmd is not SW_HIDE, so change it
// manually to avoid unhiding a hidden window with the subsequent call to
// SetWindowPlacement().
if (!isVisible())
windowPlacement.showCmd = SW_HIDE;
SetWindowPlacement(m_data.hwnd, &windowPlacement);
}
// QTBUG-17548: We send expose events when receiving WM_Paint, but for