Windows QPA: Clear maximized state before setting the normal geometry.
A sequence of state changes fullscreen, maximized and back can leave the
window in a maximized state after setting the top level style. It needs to
be cleared before applying the normal geometry, otherwise, the window ends
up with a maximized button and normal geometry. Amends change
e3288f246b
.
Task-number: QTBUG-49709
Change-Id: I0bb4ac1d60693e25d5ee74e763d293405636bb13
Reviewed-by: Błażej Szczygieł <spaz16@wp.pl>
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
f24536f8a5
commit
ae572a9808
@ -224,6 +224,30 @@ static inline QRect frameGeometry(HWND hwnd, bool topLevel)
|
||||
return qrectFromRECT(rect);
|
||||
}
|
||||
|
||||
// Return the visibility of the Window (except full screen since it is not a window state).
|
||||
static QWindow::Visibility windowVisibility_sys(HWND hwnd)
|
||||
{
|
||||
if (!IsWindowVisible(hwnd))
|
||||
return QWindow::Hidden;
|
||||
#ifndef Q_OS_WINCE
|
||||
WINDOWPLACEMENT windowPlacement;
|
||||
windowPlacement.length = sizeof(WINDOWPLACEMENT);
|
||||
if (GetWindowPlacement(hwnd, &windowPlacement)) {
|
||||
switch (windowPlacement.showCmd) {
|
||||
case SW_SHOWMINIMIZED:
|
||||
case SW_MINIMIZE:
|
||||
case SW_FORCEMINIMIZE:
|
||||
return QWindow::Minimized;
|
||||
case SW_SHOWMAXIMIZED:
|
||||
return QWindow::Maximized;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // !Q_OS_WINCE
|
||||
return QWindow::Windowed;
|
||||
}
|
||||
|
||||
static inline QSize clientSize(HWND hwnd)
|
||||
{
|
||||
RECT rect = { 0, 0, 0, 0 };
|
||||
@ -1764,6 +1788,10 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
|
||||
swpf |= SWP_NOSIZE | SWP_NOMOVE;
|
||||
const bool wasSync = testFlag(SynchronousGeometryChangeEvent);
|
||||
setFlag(SynchronousGeometryChangeEvent);
|
||||
// After maximized/fullscreen; the window can be in a maximized state. Clear
|
||||
// it before applying the normal geometry.
|
||||
if (windowVisibility_sys(m_data.hwnd) == QWindow::Maximized)
|
||||
ShowWindow(m_data.hwnd, SW_SHOWNOACTIVATE);
|
||||
SetWindowPos(m_data.hwnd, 0, m_savedFrameGeometry.x(), m_savedFrameGeometry.y(),
|
||||
m_savedFrameGeometry.width(), m_savedFrameGeometry.height(), swpf);
|
||||
if (!wasSync)
|
||||
|
Loading…
Reference in New Issue
Block a user