From 859a3bb5986091c4c30ca2040f09d15567032e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 13 Jun 2015 01:48:11 +0200 Subject: [PATCH] [wayland] Add support for PlasmaWindowManagement interface So far this only allows to trigger show desktop functionality and exports the state. In future this should be restricted to just one dedicated desktop shell process. --- main_wayland.cpp | 1 + wayland_server.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ wayland_server.h | 3 +++ 3 files changed, 46 insertions(+) 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;