summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-25 15:06:32 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-29 15:16:44 +0000
commitae572a980883cc96d5594b8f679aa5471a01843d (patch)
treedf94454bfe4297ece69e420badb37667b634bc12 /src/plugins/platforms
parentf24536f8a533a3001c3a142f9d5c4bc4036bc5bf (diff)
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 e3288f246b44ba2b6d90b90eb99ab61f496d8d57. Task-number: QTBUG-49709 Change-Id: I0bb4ac1d60693e25d5ee74e763d293405636bb13 Reviewed-by: Błażej Szczygieł <spaz16@wp.pl> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index cac8ec5ecc..7f45b4817a 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -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)