xcb: do not create a dummy QScreen when there are no outputs

Whenever a QWindow is associated with a QScreen, the screen is expected
to be a real working one, so that rendering continues to be possible.
This partially reverts 52f5e50f11

[ChangeLog][QPA][Xcb] If all QScreens (xcb outputs) are disconnected
while an application is running, QGuiApplication::primaryScreen() will
return null until a screen is connected again.

Task-number: QTBUG-40174
Task-number: QTBUG-42985
Change-Id: Id1b29dd70eaf3f2e7fd477516ce7e2bf24e095f6
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
bb10
Shawn Rutledge 2015-03-02 10:48:21 +01:00
parent d7401c32c5
commit 51ada7734a
3 changed files with 16 additions and 11 deletions

View File

@ -873,9 +873,14 @@ QWindowList QGuiApplication::topLevelWindows()
}
/*!
Returns the primary (or default) screen of the application.
Returns the primary (or default) screen of the application, or null if there is none
This will be the screen where QWindows are initially shown, unless otherwise specified.
On some platforms, it may be null when there are actually no screens connected.
It is not possible to start a new QGuiApplication while there are no screens.
Applications which were running at the time the primary screen was removed
will stop rendering graphics until one or more screens are restored.
*/
QScreen *QGuiApplication::primaryScreen()
{

View File

@ -215,16 +215,6 @@ void QXcbConnection::updateScreens()
}
free(primary);
}
// If there's no randr extension, or there was some error above, or the screen
// doesn't have outputs for some other reason (e.g. on VNC or ssh -X), just assume there is one screen.
if (connectedOutputCount == 0) {
qCDebug(lcQpaScreen, "found a screen with zero outputs");
QXcbScreen *screen = findOrCreateScreen(newScreens, xcbScreenNumber, xcbScreen);
siblings << screen;
activeScreens << screen;
if (!primaryScreen)
primaryScreen = screen;
}
foreach (QPlatformScreen* s, siblings)
((QXcbScreen*)s)->setVirtualSiblings(siblings);
xcb_screen_next(&it);
@ -282,6 +272,11 @@ void QXcbConnection::updateScreens()
if (!m_screens.isEmpty())
qCDebug(lcQpaScreen) << "primary output is" << m_screens.first()->name();
else
// QTBUG-40174, QTBUG-42985: If there are no outputs, then there must be
// no QScreen instances; a Qt application can survive this situation, and
// start rendering again later when there is a screen again.
qCDebug(lcQpaScreen) << "xcb connection has no outputs";
}
QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, const char *displayName)

View File

@ -238,6 +238,11 @@
\property QDesktopWidget::screenCount
\brief the number of screens currently available on the system.
Note that on some platforms, screenCount will be zero if there are actually
no screens connected. Applications which were running at the time the
screenCount went to zero will stop rendering graphics until one or more
screens are restored.
\since 4.6
*/