diff --git a/autotests/wayland/move_resize_window_test.cpp b/autotests/wayland/move_resize_window_test.cpp --- a/autotests/wayland/move_resize_window_test.cpp +++ b/autotests/wayland/move_resize_window_test.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -62,12 +63,15 @@ void testGrowShrink(); void testPointerMoveEnd_data(); void testPointerMoveEnd(); + void testPlasmaShellSurfaceMovable_data(); + void testPlasmaShellSurfaceMovable(); private: KWayland::Client::ConnectionThread *m_connection = nullptr; KWayland::Client::Compositor *m_compositor = nullptr; KWayland::Client::ShmPool *m_shm = nullptr; KWayland::Client::Shell *m_shell = nullptr; + KWayland::Client::PlasmaShell *m_plasmaShell = nullptr; KWayland::Client::EventQueue *m_queue = nullptr; QThread *m_thread = nullptr; }; @@ -132,6 +136,8 @@ QVERIFY(m_shm->isValid()); m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this); QVERIFY(m_shell->isValid()); + m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name, registry.interface(Registry::Interface::PlasmaShell).version, this); + QVERIFY(m_plasmaShell->isValid()); screens()->setCurrent(0); } @@ -144,6 +150,8 @@ m_shm = nullptr; delete m_shell; m_shell = nullptr; + delete m_plasmaShell; + m_plasmaShell = nullptr; delete m_queue; m_queue = nullptr; if (m_thread) { @@ -517,6 +525,52 @@ QVERIFY(!c->isMove()); } +void MoveResizeWindowTest::testPlasmaShellSurfaceMovable_data() +{ + QTest::addColumn("role"); + QTest::addColumn("movable"); + QTest::addColumn("movableAcrossScreens"); + QTest::addColumn("resizable"); + + QTest::newRow("normal") << KWayland::Client::PlasmaShellSurface::Role::Normal << true << true << true; + QTest::newRow("desktop") << KWayland::Client::PlasmaShellSurface::Role::Desktop << false << false << false; + QTest::newRow("panel") << KWayland::Client::PlasmaShellSurface::Role::Panel << false << false << false; + QTest::newRow("osd") << KWayland::Client::PlasmaShellSurface::Role::OnScreenDisplay << false << false << false; +} + +void MoveResizeWindowTest::testPlasmaShellSurfaceMovable() +{ + // this test verifies that certain window types from PlasmaShellSurface are not moveable or resizable + using namespace KWayland::Client; + QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); + QVERIFY(clientAddedSpy.isValid()); + + QScopedPointer surface(m_compositor->createSurface()); + QVERIFY(!surface.isNull()); + + QScopedPointer shellSurface(m_shell->createSurface(surface.data())); + QVERIFY(!shellSurface.isNull()); + // and a PlasmaShellSurface + QScopedPointer plasmaSurface(m_plasmaShell->createSurface(surface.data())); + QVERIFY(!plasmaSurface.isNull()); + QFETCH(KWayland::Client::PlasmaShellSurface::Role, role); + plasmaSurface->setRole(role); + // let's render + QImage img(QSize(100, 50), QImage::Format_ARGB32); + img.fill(Qt::blue); + surface->attachBuffer(m_shm->createBuffer(img)); + surface->damage(QRect(0, 0, 100, 50)); + surface->commit(Surface::CommitFlag::None); + + m_connection->flush(); + QVERIFY(clientAddedSpy.wait()); + AbstractClient *c = clientAddedSpy.first().first().value(); + QVERIFY(c); + QTEST(c->isMovable(), "movable"); + QTEST(c->isMovableAcrossScreens(), "movableAcrossScreens"); + QTEST(c->isResizable(), "resizable"); +} + } WAYLANDTEST_MAIN(KWin::MoveResizeWindowTest) diff --git a/shell_client.cpp b/shell_client.cpp --- a/shell_client.cpp +++ b/shell_client.cpp @@ -502,16 +502,25 @@ bool ShellClient::isMovable() const { + if (m_plasmaShellSurface) { + return m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Normal; + } return true; } bool ShellClient::isMovableAcrossScreens() const { + if (m_plasmaShellSurface) { + return m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Normal; + } return true; } bool ShellClient::isResizable() const { + if (m_plasmaShellSurface) { + return m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Normal; + } return true; }