diff --git a/src/wayland/autotests/client/test_plasma_window_model.cpp b/src/wayland/autotests/client/test_plasma_window_model.cpp index 674b899ff0..eb028946be 100644 --- a/src/wayland/autotests/client/test_plasma_window_model.cpp +++ b/src/wayland/autotests/client/test_plasma_window_model.cpp @@ -187,9 +187,6 @@ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ m_display->dispatchEvents(); QSignalSpy dataChangedSpy(model, &PlasmaWindowModel::dataChanged); VERIFY(dataChangedSpy.isValid()); - // just creating sends one changed, this could be improved in the protocol - VERIFY(dataChangedSpy.wait()); - dataChangedSpy.clear(); const QModelIndex index = model->index(0); COMPARE(model->data(index, role).toBool(), false); @@ -454,9 +451,6 @@ void PlasmaWindowModelTest::testTitle() m_display->dispatchEvents(); QSignalSpy dataChangedSpy(model, &PlasmaWindowModel::dataChanged); QVERIFY(dataChangedSpy.isValid()); - // just creating sends one changed, this could be improved in the protocol - QVERIFY(dataChangedSpy.wait()); - dataChangedSpy.clear(); const QModelIndex index = model->index(0); QCOMPARE(model->data(index, Qt::DisplayRole).toString(), QString()); @@ -482,9 +476,6 @@ void PlasmaWindowModelTest::testAppId() m_display->dispatchEvents(); QSignalSpy dataChangedSpy(model, &PlasmaWindowModel::dataChanged); QVERIFY(dataChangedSpy.isValid()); - // just creating sends one changed, this could be improved in the protocol - QVERIFY(dataChangedSpy.wait()); - dataChangedSpy.clear(); const QModelIndex index = model->index(0); QCOMPARE(model->data(index, PlasmaWindowModel::AppId).toString(), QString()); @@ -510,9 +501,6 @@ void PlasmaWindowModelTest::testVirtualDesktop() m_display->dispatchEvents(); QSignalSpy dataChangedSpy(model, &PlasmaWindowModel::dataChanged); QVERIFY(dataChangedSpy.isValid()); - // just creating sends one changed, this could be improved in the protocol - QVERIFY(dataChangedSpy.wait()); - dataChangedSpy.clear(); const QModelIndex index = model->index(0); QCOMPARE(model->data(index, PlasmaWindowModel::VirtualDesktop).toInt(), 0); diff --git a/src/wayland/autotests/client/test_wayland_windowmanagement.cpp b/src/wayland/autotests/client/test_wayland_windowmanagement.cpp index f94048633e..4e98ab1bd7 100644 --- a/src/wayland/autotests/client/test_wayland_windowmanagement.cpp +++ b/src/wayland/autotests/client/test_wayland_windowmanagement.cpp @@ -313,16 +313,16 @@ void TestWindowManagement::testDeleteActiveWindow() void TestWindowManagement::testCreateAfterUnmap() { // this test verifies that we don't get a protocol error on client side when creating an already unmapped window. - QSignalSpy windowSpy(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated); - QVERIFY(windowSpy.isValid()); + QCOMPARE(m_windowManagement->children().count(), 1); // create and unmap in one go // client will first handle the create, the unmap will be sent once the server side is bound auto serverWindow = m_windowManagementInterface->createWindow(this); serverWindow->unmap(); QCOMPARE(m_windowManagementInterface->children().count(), 0); - QVERIFY(windowSpy.wait()); - QCOMPARE(windowSpy.count(), 1); - auto window = windowSpy.first().first().value(); + QCoreApplication::instance()->processEvents(); + QCoreApplication::instance()->processEvents(QEventLoop::WaitForMoreEvents); + QTRY_COMPARE(m_windowManagement->children().count(), 2); + auto window = dynamic_cast(m_windowManagement->children().last()); QVERIFY(window); // now this is not yet on the server, on the server it will be after next roundtrip // which we can trigger by waiting for destroy of the newly created window. @@ -330,6 +330,7 @@ void TestWindowManagement::testCreateAfterUnmap() QSignalSpy clientDestroyedSpy(window, &QObject::destroyed); QVERIFY(clientDestroyedSpy.isValid()); QVERIFY(clientDestroyedSpy.wait()); + QCOMPARE(m_windowManagement->children().count(), 1); // the server side created a helper PlasmaWindowInterface with PlasmaWindowManagementInterface as parent // it emitted unmapped so we can be sure it will be destroyed directly QCOMPARE(m_windowManagementInterface->children().count(), 1); diff --git a/src/wayland/plasmawindowmanagement_interface.cpp b/src/wayland/plasmawindowmanagement_interface.cpp index d106941055..8f46e10f80 100644 --- a/src/wayland/plasmawindowmanagement_interface.cpp +++ b/src/wayland/plasmawindowmanagement_interface.cpp @@ -171,8 +171,8 @@ void PlasmaWindowManagementInterface::Private::getWindowCallback(wl_client *clie if (it == p->windows.constEnd()) { // create a temp window just for the resource and directly send an unmapped PlasmaWindowInterface *window = new PlasmaWindowInterface(p->q, p->q); + window->d->unmapped = true; window->d->createResource(resource, id); - window->unmap(); return; } (*it)->d->createResource(resource, id); @@ -320,6 +320,14 @@ void PlasmaWindowInterface::Private::createResource(wl_resource *parent, uint32_ } org_kde_plasma_window_send_state_changed(resource, m_state); org_kde_plasma_window_send_themed_icon_name_changed(resource, m_themedIconName.toUtf8().constData()); + + if (unmapped) { + org_kde_plasma_window_send_unmapped(resource); + } + + if (wl_resource_get_version(resource) >= ORG_KDE_PLASMA_WINDOW_INITIAL_STATE_SINCE_VERSION) { + org_kde_plasma_window_send_initial_state(resource); + } c->flush(); }