summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJocelyn Turcotte <jturcotte@woboq.com>2017-02-24 09:18:10 -0800
committerJocelyn Turcotte (Woboq GmbH) <jturcotte@woboq.com>2017-03-08 09:23:44 +0000
commit8afc6146be513e7adee6e4ade342e28951bfefc6 (patch)
tree19bddfb295d0280f95da149618e51aa05a98fb67 /src
parent40ace7a2a0f5cf1e3f097500240b17a2b9cabf2d (diff)
Windows QPA: Better recover from removed screens when fullscreen
QWindowsWindow::handleResized would call isFullScreen_sys which checks if the window's screen geometry matches the one of the window. When switching back from fullscreen, Windows will have set the geometry to fill the next window, but we don't switch QScreen until later in that function, inside handleGeometryChange. This would result in our window to take the whole screen geometry, but the FullScreen state wouldn't be transferred to the new screen. Fix the issue by using screenForGeometry and check if we are fullscreen on any screen. Also make sure that we check the validity of m_savedFrameGeometry when restoring after a screen remove, since we would previously restore to an area not covered by any screen anymore. Change-Id: I43bc02738007918e9a26c1d27a699c51d3365034 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 0028ad1bd0..79dce2fc43 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1750,10 +1750,9 @@ bool QWindowsWindow::isFullScreen_sys() const
const QWindow *w = window();
if (!w->isTopLevel())
return false;
- const QScreen *screen = w->screen();
- if (!screen)
- screen = QGuiApplication::primaryScreen();
- return screen && geometry_sys() == QHighDpi::toNativePixels(screen->geometry(), w);
+ QRect geometry = geometry_sys();
+ QPlatformScreen *screen = screenForGeometry(geometry);
+ return screen && geometry == QHighDpi::toNativePixels(screen->geometry(), screen);
}
/*!
@@ -1825,6 +1824,13 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
newStyle |= WS_VISIBLE;
setStyle(newStyle);
+ const QScreen *screen = window()->screen();
+ if (!screen)
+ screen = QGuiApplication::primaryScreen();
+ // That area of the virtual desktop might not be covered by a screen anymore.
+ if (!screen->geometry().intersects(m_savedFrameGeometry))
+ m_savedFrameGeometry.moveTo(screen->geometry().topLeft());
+
UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE;
if (!m_savedFrameGeometry.isValid())
swpf |= SWP_NOSIZE | SWP_NOMOVE;