diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index 124ad830f1..4f61e3bbc8 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -212,7 +212,7 @@ void Helper::init() Decoration::Decoration(QObject *parent, const QVariantList &args) - : KDecoration2::Decoration(parent) + : KDecoration2::Decoration(parent, args) , m_item(nullptr) , m_borders(nullptr) , m_maximizedBorders(nullptr) diff --git a/decorations/decorationbridge.cpp b/decorations/decorationbridge.cpp index 119694d6ed..fbff6787ed 100644 --- a/decorations/decorationbridge.cpp +++ b/decorations/decorationbridge.cpp @@ -47,20 +47,19 @@ namespace Decoration static const QString s_pluginName = QStringLiteral("org.kde.kdecoration2"); +KWIN_SINGLETON_FACTORY(DecorationBridge) + DecorationBridge::DecorationBridge(QObject *parent) - : QObject(parent) - , KDecoration2::DecorationBridge() + : KDecoration2::DecorationBridge(parent) , m_factory(nullptr) , m_blur(false) , m_settings() { } -DecorationBridge::~DecorationBridge() = default; - -DecorationBridge *DecorationBridge::self() +DecorationBridge::~DecorationBridge() { - return static_cast(KDecoration2::DecorationBridge::self()); + s_self = nullptr; } static QString readPlugin() @@ -192,11 +191,12 @@ KDecoration2::Decoration *DecorationBridge::createDecoration(Client *client) if (!m_factory) { return nullptr; } - QVariantList args; + QVariantMap args({ {QStringLiteral("bridge"), QVariant::fromValue(this)} }); + if (!m_theme.isEmpty()) { - args << QVariantMap({ {QStringLiteral("theme"), m_theme} }); + args.insert(QStringLiteral("theme"), m_theme); } - auto deco = m_factory->create(client, args); + auto deco = m_factory->create(client, QVariantList({args})); deco->setSettings(m_settings); deco->init(); return deco; diff --git a/decorations/decorationbridge.h b/decorations/decorationbridge.h index 31b2d9765a..76bd471e15 100644 --- a/decorations/decorationbridge.h +++ b/decorations/decorationbridge.h @@ -20,6 +20,8 @@ along with this program. If not, see . #ifndef KWIN_DECORATION_BRIDGE_H #define KWIN_DECORATION_BRIDGE_H +#include + #include #include @@ -40,11 +42,10 @@ class Client; namespace Decoration { -class DecorationBridge : public QObject, public KDecoration2::DecorationBridge +class DecorationBridge : public KDecoration2::DecorationBridge { Q_OBJECT public: - explicit DecorationBridge(QObject *parent); virtual ~DecorationBridge(); void init(); @@ -64,7 +65,6 @@ public: return m_settings; } - static DecorationBridge *self(); private: void loadMetaData(const QJsonObject &object); void findTheme(const QVariantMap &map); @@ -76,6 +76,7 @@ private: QString m_defaultTheme; QString m_theme; QSharedPointer m_settings; + KWIN_SINGLETON(DecorationBridge) }; } // Decoration } // KWin diff --git a/workspace.cpp b/workspace.cpp index 371f9029fb..f837ac0d01 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -214,9 +214,9 @@ Workspace::Workspace(bool restore) m_compositor = Compositor::create(this); connect(this, SIGNAL(currentDesktopChanged(int,KWin::Client*)), m_compositor, SLOT(addRepaintFull())); - new Decoration::DecorationBridge(this); - Decoration::DecorationBridge::self()->init(); - connect(this, &Workspace::configChanged, Decoration::DecorationBridge::self(), &Decoration::DecorationBridge::reconfigure); + auto decorationBridge = Decoration::DecorationBridge::create(this); + decorationBridge->init(); + connect(this, &Workspace::configChanged, decorationBridge, &Decoration::DecorationBridge::reconfigure); new DBusInterface(this);