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
icc-effect-5.14.5
David Edmundson 2018-01-04 18:32:18 +00:00
parent ac2f41c86d
commit 01d6878dc2
4 changed files with 38 additions and 9 deletions

View File

@ -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/plasmawindowmanagement_interface.h>
#include <KWayland/Server/appmenu_interface.h>
#include <KWayland/Server/server_decoration_palette_interface.h>
#include <KDesktopFile>
@ -59,7 +60,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using namespace KWayland::Server;
static const QByteArray s_schemePropertyName = QByteArrayLiteral("KDE_COLOR_SCHEME_PATH");
static const QByteArray s_skipClosePropertyName = QByteArrayLiteral("KWIN_SKIP_CLOSE_ANIMATION");
namespace KWin
@ -1387,14 +1387,25 @@ void ShellClient::installAppMenu(AppMenuInterface *menu)
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)
{
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) {
QDynamicPropertyChangeEvent *pe = static_cast<QDynamicPropertyChangeEvent*>(event);
if (pe->propertyName() == s_skipClosePropertyName) {
@ -1406,8 +1417,8 @@ bool ShellClient::eventFilter(QObject *watched, QEvent *event)
void ShellClient::updateColorScheme()
{
if (m_qtExtendedSurface) {
AbstractClient::updateColorScheme(rules()->checkDecoColor(m_qtExtendedSurface->property(s_schemePropertyName.constData()).toString()));
if (m_paletteInterface) {
AbstractClient::updateColorScheme(rules()->checkDecoColor(m_paletteInterface->palette()));
} else {
AbstractClient::updateColorScheme(rules()->checkDecoColor(QString()));
}

View File

@ -29,6 +29,7 @@ namespace Server
{
class ShellSurfaceInterface;
class ServerSideDecorationInterface;
class ServerSideDecorationPaletteInterface;
class AppMenuInterface;
class PlasmaShellSurfaceInterface;
class QtExtendedSurfaceInterface;
@ -137,6 +138,7 @@ public:
void installQtExtendedSurface(KWayland::Server::QtExtendedSurfaceInterface *surface);
void installServerSideDecoration(KWayland::Server::ServerSideDecorationInterface *decoration);
void installAppMenu(KWayland::Server::AppMenuInterface *appmenu);
void installPalette(KWayland::Server::ServerSideDecorationPaletteInterface *palette);
bool isInitialPositionSet() const override;
@ -220,6 +222,7 @@ private:
QPointer<KWayland::Server::PlasmaShellSurfaceInterface> m_plasmaShellSurface;
QPointer<KWayland::Server::QtExtendedSurfaceInterface> m_qtExtendedSurface;
QPointer<KWayland::Server::AppMenuInterface> m_appMenuInterface;
QPointer<KWayland::Server::ServerSideDecorationPaletteInterface> m_paletteInterface;
KWayland::Server::ServerSideDecorationInterface *m_serverDecoration = nullptr;
bool m_userNoBorder = false;
bool m_fullScreen = false;

View File

@ -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/seat_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/subcompositor_interface.h>
#include <KWayland/Server/blur_interface.h>
@ -156,6 +157,9 @@ void WaylandServer::createSurface(T *surface)
if (auto menu = m_appMenuManager->appMenuForSurface(surface->surface())) {
client->installAppMenu(menu);
}
if (auto palette = m_paletteManager->paletteForSurface(surface->surface())) {
client->installPalette(palette);
}
if (client->isInternal()) {
m_internalClients << client;
} else {
@ -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->create();

View File

@ -48,6 +48,7 @@ class DataDeviceInterface;
class ShellInterface;
class SeatInterface;
class ServerSideDecorationManagerInterface;
class ServerSideDecorationPaletteManagerInterface;
class SurfaceInterface;
class OutputInterface;
class PlasmaShellInterface;
@ -221,6 +222,7 @@ private:
KWayland::Server::ServerSideDecorationManagerInterface *m_decorationManager = nullptr;
KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr;
KWayland::Server::AppMenuManagerInterface *m_appMenuManager = nullptr;
KWayland::Server::ServerSideDecorationPaletteManagerInterface *m_paletteManager = nullptr;
struct {
KWayland::Server::ClientConnection *client = nullptr;
QMetaObject::Connection destroyConnection;