Commit 01d6878d authored by David Edmundson's avatar David Edmundson

Add explicit protocol for colour scheme management

Summary:
To replace the deprecated/broken qt extended surface

BUG: 385214

Test Plan: Ran test in plasma-integration

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D9660
parent ac2f41c8
...@@ -47,6 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -47,6 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/qtsurfaceextension_interface.h> #include <KWayland/Server/qtsurfaceextension_interface.h>
#include <KWayland/Server/plasmawindowmanagement_interface.h> #include <KWayland/Server/plasmawindowmanagement_interface.h>
#include <KWayland/Server/appmenu_interface.h> #include <KWayland/Server/appmenu_interface.h>
#include <KWayland/Server/server_decoration_palette_interface.h>
#include <KDesktopFile> #include <KDesktopFile>
...@@ -59,7 +60,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -59,7 +60,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using namespace KWayland::Server; using namespace KWayland::Server;
static const QByteArray s_schemePropertyName = QByteArrayLiteral("KDE_COLOR_SCHEME_PATH");
static const QByteArray s_skipClosePropertyName = QByteArrayLiteral("KWIN_SKIP_CLOSE_ANIMATION"); static const QByteArray s_skipClosePropertyName = QByteArrayLiteral("KWIN_SKIP_CLOSE_ANIMATION");
namespace KWin namespace KWin
...@@ -1387,14 +1387,25 @@ void ShellClient::installAppMenu(AppMenuInterface *menu) ...@@ -1387,14 +1387,25 @@ void ShellClient::installAppMenu(AppMenuInterface *menu)
updateMenu(menu->address()); updateMenu(menu->address());
} }
void ShellClient::installPalette(ServerSideDecorationPaletteInterface *palette)
{
m_paletteInterface = palette;
auto updatePalette = [this](const QString &palette) {
AbstractClient::updateColorScheme(rules()->checkDecoColor(palette));
};
connect(m_paletteInterface, &ServerSideDecorationPaletteInterface::paletteChanged, this, [=](const QString &palette) {
updatePalette(palette);
});
connect(m_paletteInterface, &QObject::destroyed, this, [=]() {
updatePalette(QString());
});
updatePalette(palette->palette());
}
bool ShellClient::eventFilter(QObject *watched, QEvent *event) bool ShellClient::eventFilter(QObject *watched, QEvent *event)
{ {
if (watched == m_qtExtendedSurface.data() && event->type() == QEvent::DynamicPropertyChange) {
QDynamicPropertyChangeEvent *pe = static_cast<QDynamicPropertyChangeEvent*>(event);
if (pe->propertyName() == s_schemePropertyName) {
AbstractClient::updateColorScheme(rules()->checkDecoColor(m_qtExtendedSurface->property(pe->propertyName().constData()).toString()));
}
}
if (watched == m_internalWindow && event->type() == QEvent::DynamicPropertyChange) { if (watched == m_internalWindow && event->type() == QEvent::DynamicPropertyChange) {
QDynamicPropertyChangeEvent *pe = static_cast<QDynamicPropertyChangeEvent*>(event); QDynamicPropertyChangeEvent *pe = static_cast<QDynamicPropertyChangeEvent*>(event);
if (pe->propertyName() == s_skipClosePropertyName) { if (pe->propertyName() == s_skipClosePropertyName) {
...@@ -1406,8 +1417,8 @@ bool ShellClient::eventFilter(QObject *watched, QEvent *event) ...@@ -1406,8 +1417,8 @@ bool ShellClient::eventFilter(QObject *watched, QEvent *event)
void ShellClient::updateColorScheme() void ShellClient::updateColorScheme()
{ {
if (m_qtExtendedSurface) { if (m_paletteInterface) {
AbstractClient::updateColorScheme(rules()->checkDecoColor(m_qtExtendedSurface->property(s_schemePropertyName.constData()).toString())); AbstractClient::updateColorScheme(rules()->checkDecoColor(m_paletteInterface->palette()));
} else { } else {
AbstractClient::updateColorScheme(rules()->checkDecoColor(QString())); AbstractClient::updateColorScheme(rules()->checkDecoColor(QString()));
} }
......
...@@ -29,6 +29,7 @@ namespace Server ...@@ -29,6 +29,7 @@ namespace Server
{ {
class ShellSurfaceInterface; class ShellSurfaceInterface;
class ServerSideDecorationInterface; class ServerSideDecorationInterface;
class ServerSideDecorationPaletteInterface;
class AppMenuInterface; class AppMenuInterface;
class PlasmaShellSurfaceInterface; class PlasmaShellSurfaceInterface;
class QtExtendedSurfaceInterface; class QtExtendedSurfaceInterface;
...@@ -137,6 +138,7 @@ public: ...@@ -137,6 +138,7 @@ public:
void installQtExtendedSurface(KWayland::Server::QtExtendedSurfaceInterface *surface); void installQtExtendedSurface(KWayland::Server::QtExtendedSurfaceInterface *surface);
void installServerSideDecoration(KWayland::Server::ServerSideDecorationInterface *decoration); void installServerSideDecoration(KWayland::Server::ServerSideDecorationInterface *decoration);
void installAppMenu(KWayland::Server::AppMenuInterface *appmenu); void installAppMenu(KWayland::Server::AppMenuInterface *appmenu);
void installPalette(KWayland::Server::ServerSideDecorationPaletteInterface *palette);
bool isInitialPositionSet() const override; bool isInitialPositionSet() const override;
...@@ -220,6 +222,7 @@ private: ...@@ -220,6 +222,7 @@ private:
QPointer<KWayland::Server::PlasmaShellSurfaceInterface> m_plasmaShellSurface; QPointer<KWayland::Server::PlasmaShellSurfaceInterface> m_plasmaShellSurface;
QPointer<KWayland::Server::QtExtendedSurfaceInterface> m_qtExtendedSurface; QPointer<KWayland::Server::QtExtendedSurfaceInterface> m_qtExtendedSurface;
QPointer<KWayland::Server::AppMenuInterface> m_appMenuInterface; QPointer<KWayland::Server::AppMenuInterface> m_appMenuInterface;
QPointer<KWayland::Server::ServerSideDecorationPaletteInterface> m_paletteInterface;
KWayland::Server::ServerSideDecorationInterface *m_serverDecoration = nullptr; KWayland::Server::ServerSideDecorationInterface *m_serverDecoration = nullptr;
bool m_userNoBorder = false; bool m_userNoBorder = false;
bool m_fullScreen = false; bool m_fullScreen = false;
......
...@@ -49,6 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -49,6 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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/server_decoration_interface.h>
#include <KWayland/Server/server_decoration_palette_interface.h>
#include <KWayland/Server/shadow_interface.h> #include <KWayland/Server/shadow_interface.h>
#include <KWayland/Server/subcompositor_interface.h> #include <KWayland/Server/subcompositor_interface.h>
#include <KWayland/Server/blur_interface.h> #include <KWayland/Server/blur_interface.h>
...@@ -156,6 +157,9 @@ void WaylandServer::createSurface(T *surface) ...@@ -156,6 +157,9 @@ void WaylandServer::createSurface(T *surface)
if (auto menu = m_appMenuManager->appMenuForSurface(surface->surface())) { if (auto menu = m_appMenuManager->appMenuForSurface(surface->surface())) {
client->installAppMenu(menu); client->installAppMenu(menu);
} }
if (auto palette = m_paletteManager->paletteForSurface(surface->surface())) {
client->installPalette(palette);
}
if (client->isInternal()) { if (client->isInternal()) {
m_internalClients << client; m_internalClients << client;
} else { } else {
...@@ -286,6 +290,15 @@ bool WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags) ...@@ -286,6 +290,15 @@ bool WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags)
} }
} }
); );
m_paletteManager = m_display->createServerSideDecorationPaletteManager(m_display);
m_paletteManager->create();
connect(m_paletteManager, &ServerSideDecorationPaletteManagerInterface::paletteCreated,
[this] (ServerSideDecorationPaletteInterface *palette) {
if (ShellClient *client = findClient(palette->surface())) {
client->installPalette(palette);
}
}
);
m_windowManagement = m_display->createPlasmaWindowManagement(m_display); m_windowManagement = m_display->createPlasmaWindowManagement(m_display);
m_windowManagement->create(); m_windowManagement->create();
......
...@@ -48,6 +48,7 @@ class DataDeviceInterface; ...@@ -48,6 +48,7 @@ class DataDeviceInterface;
class ShellInterface; class ShellInterface;
class SeatInterface; class SeatInterface;
class ServerSideDecorationManagerInterface; class ServerSideDecorationManagerInterface;
class ServerSideDecorationPaletteManagerInterface;
class SurfaceInterface; class SurfaceInterface;
class OutputInterface; class OutputInterface;
class PlasmaShellInterface; class PlasmaShellInterface;
...@@ -221,6 +222,7 @@ private: ...@@ -221,6 +222,7 @@ private:
KWayland::Server::ServerSideDecorationManagerInterface *m_decorationManager = nullptr; KWayland::Server::ServerSideDecorationManagerInterface *m_decorationManager = nullptr;
KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr; KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr;
KWayland::Server::AppMenuManagerInterface *m_appMenuManager = nullptr; KWayland::Server::AppMenuManagerInterface *m_appMenuManager = nullptr;
KWayland::Server::ServerSideDecorationPaletteManagerInterface *m_paletteManager = nullptr;
struct { struct {
KWayland::Server::ClientConnection *client = nullptr; KWayland::Server::ClientConnection *client = nullptr;
QMetaObject::Connection destroyConnection; QMetaObject::Connection destroyConnection;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment