diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-04-23 16:46:26 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-24 11:10:02 +0200 |
commit | ded4613ae43842d4b960137843eb83a7472adc65 (patch) | |
tree | bece8b7e928e36f056387aed12ad8623730223e7 /src/plugins | |
parent | b4985215df767c14ddd888cbb2919be3a7617cfd (diff) |
Windows: Position full screen windows on the correct screen.
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 <samuel.rodal@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
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); |