From ded4613ae43842d4b960137843eb83a7472adc65 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 23 Apr 2013 16:46:26 +0200 Subject: Windows: Position full screen windows on the correct screen. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Find effective screen by searching the virtual sibling that contains the center as does QDesktopWidget::screenNumber(). Task-number: QTBUG-30724 Change-Id: I8441ab4f3e5ee8169613a82f150d1a4f1777b662 Reviewed-by: Samuel Rødal --- src/plugins/platforms/windows/qwindowswindow.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 2a5e08cf41..9a9877b43f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1366,9 +1366,23 @@ void QWindowsWindow::setWindowState(Qt::WindowState state) } } +// Return the effective screen for full screen mode in a virtual desktop. +static const QScreen *effectiveScreen(const QWindow *w) +{ + QPoint center = w->geometry().center(); + if (!w->isTopLevel()) + center = w->mapToGlobal(center); + const QScreen *screen = w->screen(); + if (!screen->geometry().contains(center)) + foreach (const QScreen *sibling, screen->virtualSiblings()) + if (sibling->geometry().contains(center)) + return sibling; + return screen; +} + bool QWindowsWindow::isFullScreen_sys() const { - return geometry_sys() == window()->screen()->geometry(); + return geometry_sys() == effectiveScreen(window())->geometry(); } /*! @@ -1444,7 +1458,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) newStyle |= WS_VISIBLE; setStyle(newStyle); - const QRect r = window()->screen()->geometry(); + const QRect r = effectiveScreen(window())->geometry(); const UINT swpf = SWP_FRAMECHANGED | SWP_NOACTIVATE; const bool wasSync = testFlag(SynchronousGeometryChangeEvent); setFlag(SynchronousGeometryChangeEvent); -- cgit v1.2.3