diff --git a/main_wayland.cpp b/main_wayland.cpp index 4411cb6524..875a6ee4ec 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -597,6 +597,7 @@ KWIN_EXPORT int kdemain(int argc, char * argv[]) server->backend()->setInitialWindowSize(initialWindowSize); } + QObject::connect(&a, &KWin::Application::workspaceCreated, server, &KWin::WaylandServer::initWorkspace); a.setStartXwayland(parser.isSet(xwaylandOption)); a.setApplicationsToStart(parser.positionalArguments()); a.setInputMethodServerToStart(parser.value(inputMethodOption)); diff --git a/wayland_server.cpp b/wayland_server.cpp index bb03996c77..cdbac2f651 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -34,6 +34,7 @@ along with this program. If not, see . #include #include #include +#include #include #include #include @@ -156,6 +157,47 @@ void WaylandServer::init(const QByteArray &socketName) } } ); + m_windowManagement = m_display->createPlasmaWindowManagement(m_display); + m_windowManagement->create(); + m_windowManagement->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Disabled); + connect(m_windowManagement, &PlasmaWindowManagementInterface::requestChangeShowingDesktop, this, + [] (PlasmaWindowManagementInterface::ShowingDesktopState state) { + if (!workspace()) { + return; + } + bool set = false; + switch (state) { + case PlasmaWindowManagementInterface::ShowingDesktopState::Disabled: + set = false; + break; + case PlasmaWindowManagementInterface::ShowingDesktopState::Enabled: + set = true; + break; + default: + Q_UNREACHABLE(); + break; + } + if (set == workspace()->showingDesktop()) { + return; + } + workspace()->setShowingDesktop(set); + } + ); +} + +void WaylandServer::initWorkspace() +{ + if (m_windowManagement) { + connect(workspace(), &Workspace::showingDesktopChanged, this, + [this] (bool set) { + using namespace KWayland::Server; + m_windowManagement->setShowingDesktopState(set ? + PlasmaWindowManagementInterface::ShowingDesktopState::Enabled : + PlasmaWindowManagementInterface::ShowingDesktopState::Disabled + ); + } + ); + } } void WaylandServer::initOutputs() diff --git a/wayland_server.h b/wayland_server.h index 8fcd380caa..011c924dab 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -44,6 +44,7 @@ class SeatInterface; class SurfaceInterface; class OutputInterface; class PlasmaShellInterface; +class PlasmaWindowManagementInterface; class QtSurfaceExtensionInterface; } } @@ -106,6 +107,7 @@ public: int createQtConnection(); void createInternalConnection(); void createDummyQtWindow(); + void initWorkspace(); KWayland::Server::ClientConnection *xWaylandConnection() const { return m_xwaylandConnection; @@ -140,6 +142,7 @@ private: KWayland::Server::SeatInterface *m_seat = nullptr; KWayland::Server::ShellInterface *m_shell = nullptr; KWayland::Server::PlasmaShellInterface *m_plasmaShell = nullptr; + KWayland::Server::PlasmaWindowManagementInterface *m_windowManagement = nullptr; KWayland::Server::QtSurfaceExtensionInterface *m_qtExtendedSurface = nullptr; KWayland::Server::ClientConnection *m_xwaylandConnection = nullptr; KWayland::Server::ClientConnection *m_inputMethodServerConnection = nullptr;