[qpa] Always keep a at least one screen

Summary:
Qt does not like having no screens. Both Qt XCB and Wayland QPAs have
systems pretend there's always at least 1 screen
present.

Kwin already uses a dummy screen on startup, this patch reinserts the
dummy screen if the platform states that all real screens are removed.

BUG: 399564

Test Plan:
Logged in, everything still worked
Did not reproduce the original bug

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16096
This commit is contained in:
David Edmundson 2018-10-10 11:14:13 +01:00
parent 43bed9a2a6
commit 6724955a76

View file

@ -205,11 +205,17 @@ QPlatformOpenGLContext *Integration::createPlatformOpenGLContext(QOpenGLContext
void Integration::initScreens()
{
QVector<Screen*> newScreens;
newScreens.reserve(qMax(screens()->count(), 1));
for (int i = 0; i < screens()->count(); i++) {
auto screen = new Screen(i);
screenAdded(screen);
newScreens << screen;
}
if (newScreens.isEmpty()) {
auto dummyScreen = new Screen(-1);
screenAdded(dummyScreen);
newScreens << dummyScreen;
}
while (!m_screens.isEmpty()) {
destroyScreen(m_screens.takeLast());
}