summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/qwaylanddisplay.cpp9
-rw-r--r--tests/auto/client/reconnect/tst_reconnect.cpp25
2 files changed, 31 insertions, 3 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index b7e212ab..911004f8 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -420,6 +420,12 @@ void QWaylandDisplay::reconnect()
qDeleteAll(mWaitingScreens);
mWaitingScreens.clear();
+ const auto screens = std::exchange(mScreens, {});
+ ensureScreen();
+ for (QWaylandScreen *screen : screens) {
+ QWindowSystemInterface::handleScreenRemoved(screen);
+ }
+
// mCompositor
mShm.reset();
mCursorThemes.clear();
@@ -449,9 +455,6 @@ void QWaylandDisplay::reconnect()
qDeleteAll(std::exchange(mInputDevices, {}));
mLastInputDevice = nullptr;
- auto screens = mScreens;
- mScreens.clear();
-
for (const RegistryGlobal &global : mGlobals) {
emit globalRemoved(global);
}
diff --git a/tests/auto/client/reconnect/tst_reconnect.cpp b/tests/auto/client/reconnect/tst_reconnect.cpp
index 93007d4c..2b6c7558 100644
--- a/tests/auto/client/reconnect/tst_reconnect.cpp
+++ b/tests/auto/client/reconnect/tst_reconnect.cpp
@@ -101,6 +101,7 @@ private Q_SLOTS:
//core
void cleanup() { QTRY_VERIFY2(m_comp->isClean(), qPrintable(m_comp->dirtyMessage())); }
void basicWindow();
+ void screens();
//input
void keyFocus();
@@ -141,6 +142,30 @@ void tst_WaylandReconnect::basicWindow()
QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel());
}
+void tst_WaylandReconnect::screens()
+{
+ QRasterWindow window;
+ window.resize(64, 48);
+ window.show();
+ QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel());
+
+ auto originalScreens = QGuiApplication::screens();
+
+ QSignalSpy screenRemovedSpy(qGuiApp, &QGuiApplication::screenRemoved);
+ QVERIFY(screenRemovedSpy.isValid());
+
+ triggerReconnect();
+
+ // All screens plus temporary placeholder screen removed
+ QCOMPARE(screenRemovedSpy.count(), originalScreens.count() + 1);
+ for (const auto &screen : std::as_const(screenRemovedSpy)) {
+ originalScreens.removeOne(screen[0].value<QScreen *>());
+ }
+ QVERIFY(originalScreens.isEmpty());
+ QVERIFY(window.screen());
+ QVERIFY(QGuiApplication::screens().contains(window.screen()));
+}
+
void tst_WaylandReconnect::keyFocus()
{
TestWindow window;