[wayland] Add support for ServerSideDecorationManager

We announce support for it and depending on whether we have a plugin
or not set the default mode to Server or None.

When a decoration interface is created it gets installed on the
ShellClient. But there it isn't properly used yet as we don't have
support for decorations in ShellClient yet.
This commit is contained in:
Martin Gräßlin 2015-12-17 11:14:54 +01:00
parent 3de3a959c6
commit 5cef26d275
5 changed files with 60 additions and 0 deletions

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "client.h" #include "client.h"
#include "composite.h" #include "composite.h"
#include "scene.h" #include "scene.h"
#include "wayland_server.h"
#include "workspace.h" #include "workspace.h"
// KDecoration // KDecoration
@ -33,6 +34,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KDecoration2/DecoratedClient> #include <KDecoration2/DecoratedClient>
#include <KDecoration2/DecorationSettings> #include <KDecoration2/DecorationSettings>
// KWayland
#include <KWayland/Server/server_decoration_interface.h>
// Frameworks // Frameworks
#include <KPluginMetaData> #include <KPluginMetaData>
#include <KPluginLoader> #include <KPluginLoader>
@ -82,8 +86,12 @@ QString DecorationBridge::readTheme() const
void DecorationBridge::init() void DecorationBridge::init()
{ {
using namespace KWayland::Server;
m_noPlugin = readNoPlugin(); m_noPlugin = readNoPlugin();
if (m_noPlugin) { if (m_noPlugin) {
if (waylandServer()) {
waylandServer()->decorationManager()->setDefaultMode(ServerSideDecorationManagerInterface::Mode::None);
}
return; return;
} }
m_plugin = readPlugin(); m_plugin = readPlugin();
@ -101,6 +109,9 @@ void DecorationBridge::init()
initPlugin(); initPlugin();
} }
} }
if (waylandServer()) {
waylandServer()->decorationManager()->setDefaultMode(m_factory ? ServerSideDecorationManagerInterface::Mode::Server : ServerSideDecorationManagerInterface::Mode::None);
}
} }
void DecorationBridge::initPlugin() void DecorationBridge::initPlugin()

View file

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/buffer_interface.h> #include <KWayland/Server/buffer_interface.h>
#include <KWayland/Server/plasmashell_interface.h> #include <KWayland/Server/plasmashell_interface.h>
#include <KWayland/Server/shadow_interface.h> #include <KWayland/Server/shadow_interface.h>
#include <KWayland/Server/server_decoration_interface.h>
#include <KWayland/Server/qtsurfaceextension_interface.h> #include <KWayland/Server/qtsurfaceextension_interface.h>
#include <KWayland/Server/plasmawindowmanagement_interface.h> #include <KWayland/Server/plasmawindowmanagement_interface.h>
@ -148,6 +149,10 @@ ShellClient::ShellClient(ShellSurfaceInterface *surface)
updateCursor(); updateCursor();
} }
); );
// check whether we have a ServerSideDecoration
if (ServerSideDecorationInterface *deco = ServerSideDecorationInterface::get(surface->surface())) {
installServerSideDecoration(deco);
}
} }
ShellClient::~ShellClient() = default; ShellClient::~ShellClient() = default;
@ -847,4 +852,29 @@ QMatrix4x4 ShellClient::inputTransformation() const
return m; return m;
} }
void ShellClient::installServerSideDecoration(KWayland::Server::ServerSideDecorationInterface *deco)
{
if (m_serverDecoration == deco) {
return;
}
m_serverDecoration = deco;
connect(m_serverDecoration, &ServerSideDecorationInterface::destroyed, this,
[this] {
// TODO: update decoration
m_serverDecoration = nullptr;
}
);
// TODO: update decoration
connect(m_serverDecoration, &ServerSideDecorationInterface::modeRequested, this,
[this] (ServerSideDecorationManagerInterface::Mode mode) {
const bool changed = mode != m_serverDecoration->mode();
// always acknowledge the requested mode
m_serverDecoration->setMode(mode);
if (changed) {
// TODO: update decoration
}
}
);
}
} }

View file

@ -27,6 +27,7 @@ namespace KWayland
namespace Server namespace Server
{ {
class ShellSurfaceInterface; class ShellSurfaceInterface;
class ServerSideDecorationInterface;
class PlasmaShellSurfaceInterface; class PlasmaShellSurfaceInterface;
class QtExtendedSurfaceInterface; class QtExtendedSurfaceInterface;
} }
@ -109,6 +110,7 @@ public:
void installPlasmaShellSurface(KWayland::Server::PlasmaShellSurfaceInterface *surface); void installPlasmaShellSurface(KWayland::Server::PlasmaShellSurfaceInterface *surface);
void installQtExtendedSurface(KWayland::Server::QtExtendedSurfaceInterface *surface); void installQtExtendedSurface(KWayland::Server::QtExtendedSurfaceInterface *surface);
void installServerSideDecoration(KWayland::Server::ServerSideDecorationInterface *decoration);
bool isInitialPositionSet() const; bool isInitialPositionSet() const;
@ -161,6 +163,7 @@ private:
NET::WindowType m_windowType = NET::Normal; NET::WindowType m_windowType = NET::Normal;
QPointer<KWayland::Server::PlasmaShellSurfaceInterface> m_plasmaShellSurface; QPointer<KWayland::Server::PlasmaShellSurfaceInterface> m_plasmaShellSurface;
QPointer<KWayland::Server::QtExtendedSurfaceInterface> m_qtExtendedSurface; QPointer<KWayland::Server::QtExtendedSurfaceInterface> m_qtExtendedSurface;
KWayland::Server::ServerSideDecorationInterface *m_serverDecoration = nullptr;
bool m_fullScreen = false; bool m_fullScreen = false;
bool m_transient = false; bool m_transient = false;
}; };

View file

@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/plasmawindowmanagement_interface.h> #include <KWayland/Server/plasmawindowmanagement_interface.h>
#include <KWayland/Server/qtsurfaceextension_interface.h> #include <KWayland/Server/qtsurfaceextension_interface.h>
#include <KWayland/Server/seat_interface.h> #include <KWayland/Server/seat_interface.h>
#include <KWayland/Server/server_decoration_interface.h>
#include <KWayland/Server/shadow_interface.h> #include <KWayland/Server/shadow_interface.h>
#include <KWayland/Server/blur_interface.h> #include <KWayland/Server/blur_interface.h>
#include <KWayland/Server/shell_interface.h> #include <KWayland/Server/shell_interface.h>
@ -219,6 +220,16 @@ void WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags)
shadowManager->create(); shadowManager->create();
m_display->createDpmsManager(m_display)->create(); m_display->createDpmsManager(m_display)->create();
m_decorationManager = m_display->createServerSideDecorationManager(m_display);
connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this,
[this] (ServerSideDecorationInterface *deco) {
if (ShellClient *c = findClient(deco->surface())) {
c->installServerSideDecoration(deco);
}
}
);
m_decorationManager->create();
} }
void WaylandServer::initWorkspace() void WaylandServer::initWorkspace()

View file

@ -43,6 +43,7 @@ class CompositorInterface;
class Display; class Display;
class ShellInterface; class ShellInterface;
class SeatInterface; class SeatInterface;
class ServerSideDecorationManagerInterface;
class SurfaceInterface; class SurfaceInterface;
class OutputInterface; class OutputInterface;
class PlasmaShellInterface; class PlasmaShellInterface;
@ -89,6 +90,9 @@ public:
KWayland::Server::PlasmaWindowManagementInterface *windowManagement() { KWayland::Server::PlasmaWindowManagementInterface *windowManagement() {
return m_windowManagement; return m_windowManagement;
} }
KWayland::Server::ServerSideDecorationManagerInterface *decorationManager() const {
return m_decorationManager;
}
QList<ShellClient*> clients() const { QList<ShellClient*> clients() const {
return m_clients; return m_clients;
} }
@ -164,6 +168,7 @@ private:
KWayland::Server::PlasmaShellInterface *m_plasmaShell = nullptr; KWayland::Server::PlasmaShellInterface *m_plasmaShell = nullptr;
KWayland::Server::PlasmaWindowManagementInterface *m_windowManagement = nullptr; KWayland::Server::PlasmaWindowManagementInterface *m_windowManagement = nullptr;
KWayland::Server::QtSurfaceExtensionInterface *m_qtExtendedSurface = nullptr; KWayland::Server::QtSurfaceExtensionInterface *m_qtExtendedSurface = nullptr;
KWayland::Server::ServerSideDecorationManagerInterface *m_decorationManager = nullptr;
struct { struct {
KWayland::Server::ClientConnection *client = nullptr; KWayland::Server::ClientConnection *client = nullptr;
QMetaObject::Connection destroyConnection; QMetaObject::Connection destroyConnection;