From 8afc6146be513e7adee6e4ade342e28951bfefc6 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 24 Feb 2017 09:18:10 -0800 Subject: 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 --- src/plugins/platforms/windows/qwindowswindow.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp') 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; -- cgit v1.2.3