90 lines
4.0 KiB
Diff
90 lines
4.0 KiB
Diff
commit 51ada7734ad780178ecced11e0dff454dfc2e5f2
|
|
Author: Shawn Rutledge <shawn.rutledge@digia.com>
|
|
Date: Mon Mar 2 10:48:21 2015 +0100
|
|
|
|
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 52f5e50f11a3ba82e32dc2efc656e4021a3fa4f5
|
|
|
|
[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>
|
|
|
|
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
|
|
index dc5501e..7f2bf16 100644
|
|
--- a/src/gui/kernel/qguiapplication.cpp
|
|
+++ b/src/gui/kernel/qguiapplication.cpp
|
|
@@ -872,9 +872,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()
|
|
{
|
|
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
|
|
index a8c1943..6efb876 100644
|
|
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
|
|
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
|
|
@@ -254,16 +254,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);
|
|
@@ -321,6 +311,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)
|
|
diff --git a/src/widgets/kernel/qdesktopwidget.qdoc b/src/widgets/kernel/qdesktopwidget.qdoc
|
|
index e8bda3c..f46a629 100644
|
|
--- a/src/widgets/kernel/qdesktopwidget.qdoc
|
|
+++ b/src/widgets/kernel/qdesktopwidget.qdoc
|
|
@@ -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
|
|
*/
|
|
|