From acb0e85bb6885ab31fc96a034a093b981abbaaf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 7 Jun 2016 12:58:58 +0200 Subject: [PATCH] Add destructor request to org_kde_kwin_shadow and org_kde_kwin_shadow_manager Summary: This improves the cleanup of a shadow from client side. The server now notices when the client destroyed the shadow. Reviewers: #plasma_on_wayland Subscribers: plasma-devel Differential Revision: https://phabricator.kde.org/D1789 --- src/wayland/autotests/client/test_shadow.cpp | 14 +------------- src/wayland/shadow_interface.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/wayland/autotests/client/test_shadow.cpp b/src/wayland/autotests/client/test_shadow.cpp index bab5938817..9fed1023bb 100644 --- a/src/wayland/autotests/client/test_shadow.cpp +++ b/src/wayland/autotests/client/test_shadow.cpp @@ -292,25 +292,13 @@ void ShadowTest::testSurfaceDestroy() QVERIFY(surfaceDestroyedSpy.isValid()); QSignalSpy shadowDestroyedSpy(serverShadow, &QObject::destroyed); QVERIFY(shadowDestroyedSpy.isValid()); - QSignalSpy clientDisconnectedSpy(serverSurface->client(), &ClientConnection::disconnected); - QVERIFY(clientDisconnectedSpy.isValid()); surface.reset(); QVERIFY(surfaceDestroyedSpy.wait()); QVERIFY(shadowDestroyedSpy.isEmpty()); // destroy the shadow shadow.reset(); - // shadow protocol doesn't have a destroy callback yet, so also disconnect - m_connection->deleteLater(); - m_connection = nullptr; - QVERIFY(clientDisconnectedSpy.wait()); - if (shadowDestroyedSpy.isEmpty()) { - QVERIFY(shadowDestroyedSpy.wait()); - } + QVERIFY(shadowDestroyedSpy.wait()); QCOMPARE(shadowDestroyedSpy.count(), 1); - m_shm->destroy(); - m_compositor->destroy(); - m_shadow->destroy(); - m_queue->destroy(); } QTEST_GUILESS_MAIN(ShadowTest) diff --git a/src/wayland/shadow_interface.cpp b/src/wayland/shadow_interface.cpp index 965a86ba93..c467fc0fd2 100644 --- a/src/wayland/shadow_interface.cpp +++ b/src/wayland/shadow_interface.cpp @@ -43,6 +43,7 @@ private: static void createCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *surface); static void unsetCallback(wl_client *client, wl_resource *resource, wl_resource *surface); + static void destroyCallback(wl_client *client, wl_resource *resource); static void unbind(wl_resource *resource); static Private *cast(wl_resource *r) { return reinterpret_cast(wl_resource_get_user_data(r)); @@ -53,12 +54,13 @@ private: static const quint32 s_version; }; -const quint32 ShadowManagerInterface::Private::s_version = 1; +const quint32 ShadowManagerInterface::Private::s_version = 2; #ifndef DOXYGEN_SHOULD_SKIP_THIS const struct org_kde_kwin_shadow_manager_interface ShadowManagerInterface::Private::s_interface = { createCallback, - unsetCallback + unsetCallback, + destroyCallback }; #endif @@ -86,6 +88,12 @@ void ShadowManagerInterface::Private::unbind(wl_resource *resource) // TODO: implement? } +void ShadowManagerInterface::Private::destroyCallback(wl_client *client, wl_resource *resource) +{ + Q_UNUSED(client) + wl_resource_destroy(resource); +} + void ShadowManagerInterface::Private::createCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *surface) { cast(resource)->createShadow(client, resource, id, surface); @@ -198,6 +206,7 @@ const struct org_kde_kwin_shadow_interface ShadowInterface::Private::s_interface offsetTopCallback, offsetRightCallback, offsetBottomCallback, + resourceDestroyedCallback }; #endif