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>
This commit is contained in:
Friedemann Kleint 2013-04-23 16:46:26 +02:00 committed by The Qt Project
parent b4985215df
commit ded4613ae4

View File

@ -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);