Restore the visibility of a moved QWindow in QWindow::screenDestroyed

QWindow::screenDestroyed triggers an move of the window to the primary
screen. This causes the screen to be destroyed and shown again on the
new QScreen.

The issue is that QWindow::destroy() hides the window but create()
doesn't set it visible, and this ultimately causes any QWindow to be
automatically hidden when their QScreen is destroyed.

As stated in the comment, it could be the intended behavior that
windows aren't shown automatically on a remaining screen like when
using two screens not logically part of the same desktop. Once the
platform plugins have access to an API allowing them to adjust the
screens of their QWindow, this patch shouldn't be needed anymore.

Change-Id: I7628377c969f79f9eebb3deabaf0470542d68a9c
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
Jocelyn Turcotte 2012-11-29 16:25:59 +01:00 committed by The Qt Project
parent 6385a182f0
commit 27a945dccd

View File

@ -1388,8 +1388,16 @@ void QWindow::setScreen(QScreen *newScreen)
void QWindow::screenDestroyed(QObject *object)
{
Q_D(QWindow);
if (object == static_cast<QObject *>(d->screen))
if (object == static_cast<QObject *>(d->screen)) {
const bool wasVisible = isVisible();
setScreen(0);
// destroy() might have hidden our window, show it again.
// This might not be the best behavior if the new screen isn't a virtual sibling
// of the old one. This can be removed once platform plugins have the power to
// update the QScreen of its QWindows itself.
if (wasVisible && d->platformWindow)
setVisible(true);
}
}
/*!