From 8edd0336e67d81e93dfe1418dbe2409e2b03d405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 7 Feb 2017 19:18:18 +0100 Subject: [PATCH] Support creation of PlasmaShellSurface prior to ShellSurface Summary: So far KWin did not support the sequence: 1. Create wl_shell 2. Create PlasmaShellSurface 3. Create wl_shell_surface KWin only supported the case that the PlasmaShellSurface is the last thing to get created. This is rather limiting and can be considered a bug. At least we had a QEXPECT_FAIL auto test for this situation. So it was a known issue. This change should make it easier to support the QtWayland changes in Qt 5.8. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D4482 --- autotests/integration/plasma_surface_test.cpp | 14 ++++---------- wayland_server.cpp | 16 ++++++++++++++++ wayland_server.h | 2 ++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp index 5cb620c779..6492149ac8 100644 --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -144,17 +144,11 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops() plasmaSurface2->setRole(role); QScopedPointer shellSurface2(Test::createShellSurface(surface2.data())); QVERIFY(!shellSurface2.isNull()); - Test::render(surface2.data(), QSize(100, 50), Qt::blue); - QVERIFY(Test::waitForWaylandWindowShown()); + auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue); + QVERIFY(c2); + QVERIFY(c != c2); - QVERIFY(workspace()->activeClient() != c); - c = workspace()->activeClient(); - QEXPECT_FAIL("Desktop", "PS before WS not supported", Continue); - QEXPECT_FAIL("Panel", "PS before WS not supported", Continue); - QEXPECT_FAIL("OSD", "PS before WS not supported", Continue); - QEXPECT_FAIL("Notification", "PS before WS not supported", Continue); - QEXPECT_FAIL("ToolTip", "PS before WS not supported", Continue); - QCOMPARE(c->isOnAllDesktops(), expectedOnAllDesktops); + QCOMPARE(c2->isOnAllDesktops(), expectedOnAllDesktops); } void PlasmaSurfaceTest::testAcceptsFocus_data() diff --git a/wayland_server.cpp b/wayland_server.cpp index 776c3af4f4..383446c99f 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -130,6 +130,15 @@ void WaylandServer::createSurface(T *surface) ScreenLocker::KSldApp::self()->lockScreenShown(); } auto client = new ShellClient(surface); + auto it = std::find_if(m_plasmaShellSurfaces.begin(), m_plasmaShellSurfaces.end(), + [client] (PlasmaShellSurfaceInterface *surface) { + return client->surface() == surface->surface(); + } + ); + if (it != m_plasmaShellSurfaces.end()) { + client->installPlasmaShellSurface(*it); + m_plasmaShellSurfaces.erase(it); + } if (client->isInternal()) { m_internalClients << client; } else { @@ -214,6 +223,13 @@ bool WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags) [this] (PlasmaShellSurfaceInterface *surface) { if (ShellClient *client = findClient(surface->surface())) { client->installPlasmaShellSurface(surface); + } else { + m_plasmaShellSurfaces << surface; + connect(surface, &QObject::destroyed, this, + [this, surface] { + m_plasmaShellSurfaces.removeOne(surface); + } + ); } } ); diff --git a/wayland_server.h b/wayland_server.h index 706de95dd2..1c6cab3732 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -50,6 +50,7 @@ class ServerSideDecorationManagerInterface; class SurfaceInterface; class OutputInterface; class PlasmaShellInterface; +class PlasmaShellSurfaceInterface; class PlasmaWindowManagementInterface; class QtSurfaceExtensionInterface; class OutputManagementInterface; @@ -232,6 +233,7 @@ private: QList m_internalClients; QHash m_clientIds; InitalizationFlags m_initFlags; + QVector m_plasmaShellSurfaces; KWIN_SINGLETON(WaylandServer) };