client: Make sure screens stay virtual siblings during reconnect

The virtual siblings of QWaylandScreen are constructed from the
list of screens in QWaylandDisplay. It is important that when a window
changes screens due to handleScreenRemoved that the screens are siblings
otherwise the platformwindow is destroyed and window becomes hidden.

Pick-to: 6.6
Change-Id: I7ceeee4e18fbdfa936fe987441d35b8a5cb1eefd
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
David Redondo 2023-07-28 15:44:55 +02:00
parent 9c3896c140
commit 63e2f90266
2 changed files with 29 additions and 11 deletions

View File

@ -421,9 +421,9 @@ void QWaylandDisplay::reconnect()
qDeleteAll(mWaitingScreens);
mWaitingScreens.clear();
const auto screens = std::exchange(mScreens, {});
ensureScreen();
for (QWaylandScreen *screen : screens) {
while (!mScreens.isEmpty()) {
auto screen = mScreens.takeLast();
ensureScreen();
QWindowSystemInterface::handleScreenRemoved(screen);
}

View File

@ -101,7 +101,7 @@ private Q_SLOTS:
//core
void cleanup() { QTRY_VERIFY2(m_comp->isClean(), qPrintable(m_comp->dirtyMessage())); }
void basicWindow();
void screens();
void multipleScreens();
//input
void keyFocus();
@ -142,12 +142,25 @@ void tst_WaylandReconnect::basicWindow()
QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel());
}
void tst_WaylandReconnect::screens()
void tst_WaylandReconnect::multipleScreens()
{
QRasterWindow window;
window.resize(64, 48);
window.show();
QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel());
exec([this] { m_comp->add<Output>(); });
QRasterWindow window1;
window1.resize(64, 48);
window1.show();
QRasterWindow window2;
window2.resize(64, 48);
window2.show();
QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel(0));
QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel(1));
// ensure they are on different outputs
exec([this] {
m_comp->surface(0)->sendEnter(m_comp->output(0));
m_comp->surface(1)->sendEnter(m_comp->output(1));
});
QTRY_VERIFY(window1.screen() != window2.screen());
auto originalScreens = QGuiApplication::screens();
@ -162,8 +175,13 @@ void tst_WaylandReconnect::screens()
originalScreens.removeOne(screen[0].value<QScreen *>());
}
QVERIFY(originalScreens.isEmpty());
QVERIFY(window.screen());
QVERIFY(QGuiApplication::screens().contains(window.screen()));
QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel(0));
QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel(1));
QVERIFY(window1.screen());
QVERIFY(window2.screen());
QVERIFY(QGuiApplication::screens().contains(window1.screen()));
QVERIFY(QGuiApplication::screens().contains(window2.screen()));
}
void tst_WaylandReconnect::keyFocus()