diff --git a/src/wayland/autotests/client/test_wayland_shell.cpp b/src/wayland/autotests/client/test_wayland_shell.cpp index 813ceea126..7e5963d100 100644 --- a/src/wayland/autotests/client/test_wayland_shell.cpp +++ b/src/wayland/autotests/client/test_wayland_shell.cpp @@ -43,6 +43,7 @@ private Q_SLOTS: void init(); void cleanup(); + void testCreateMultiple(); void testFullscreen(); void testPing(); void testTitle(); @@ -169,6 +170,43 @@ void TestWaylandShell::cleanup() m_display = nullptr; } +void TestWaylandShell::testCreateMultiple() +{ + using namespace KWayland::Server; + using namespace KWayland::Client; + + QScopedPointer s1(m_compositor->createSurface()); + QScopedPointer s2(m_compositor->createSurface()); + QVERIFY(!s1.isNull()); + QVERIFY(s1->isValid()); + QVERIFY(!s2.isNull()); + QVERIFY(s2->isValid()); + + QSignalSpy serverSurfaceSpy(m_shellInterface, SIGNAL(surfaceCreated(KWayland::Server::ShellSurfaceInterface*))); + QVERIFY(serverSurfaceSpy.isValid()); + QScopedPointer surface1(m_shell->createSurface(s1.data())); + QVERIFY(!surface1.isNull()); + QVERIFY(surface1->isValid()); + + QVERIFY(serverSurfaceSpy.wait()); + QCOMPARE(serverSurfaceSpy.count(), 1); + + QScopedPointer surface2(m_shell->createSurface(s2.data())); + QVERIFY(!surface2.isNull()); + QVERIFY(surface2->isValid()); + + QVERIFY(serverSurfaceSpy.wait()); + QCOMPARE(serverSurfaceSpy.count(), 2); + + // try creating for one which already exist should not be possible + QScopedPointer surface3(m_shell->createSurface(s2.data())); + QVERIFY(!surface3.isNull()); + QVERIFY(surface3->isValid()); + + QVERIFY(!serverSurfaceSpy.wait(100)); + QCOMPARE(serverSurfaceSpy.count(), 2); +} + void TestWaylandShell::testFullscreen() { using namespace KWayland::Server; diff --git a/src/wayland/server/shell_interface.cpp b/src/wayland/server/shell_interface.cpp index 069efa3bdf..13afb8220a 100644 --- a/src/wayland/server/shell_interface.cpp +++ b/src/wayland/server/shell_interface.cpp @@ -176,7 +176,7 @@ void ShellInterface::Private::createSurface(wl_client *client, uint32_t version, return surface == s->surface(); } ); - if (it != surfaces.constBegin()) { + if (it != surfaces.constEnd()) { wl_resource_post_error(surface->surface(), WL_DISPLAY_ERROR_INVALID_OBJECT, "ShellSurface already created"); return; }