From a002442224633f49249c869a45a040c595a6d504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 12 Aug 2015 10:29:03 +0200 Subject: [PATCH] [decorations] Bring back option NoPlugin The option NoPlugin allows to disable window decoration plugins. It used to exist with the old decoration library but got unfortunately lost during the switch. This change brings back the option and also allows runtime changes of the option. REVIEW: 124708 --- decorations/decorationbridge.cpp | 30 ++++++++++++++++++++++++++++++ decorations/decorationbridge.h | 1 + 2 files changed, 31 insertions(+) diff --git a/decorations/decorationbridge.cpp b/decorations/decorationbridge.cpp index 3795cb7c78..19c165160b 100644 --- a/decorations/decorationbridge.cpp +++ b/decorations/decorationbridge.cpp @@ -56,6 +56,7 @@ DecorationBridge::DecorationBridge(QObject *parent) , m_factory(nullptr) , m_blur(false) , m_settings() + , m_noPlugin(false) { } @@ -69,6 +70,11 @@ static QString readPlugin() return KSharedConfig::openConfig(KWIN_CONFIG)->group(s_pluginName).readEntry("library", s_defaultPlugin); } +static bool readNoPlugin() +{ + return KSharedConfig::openConfig(KWIN_CONFIG)->group(s_pluginName).readEntry("NoPlugin", false); +} + QString DecorationBridge::readTheme() const { return KSharedConfig::openConfig(KWIN_CONFIG)->group(s_pluginName).readEntry("theme", m_defaultTheme); @@ -76,6 +82,10 @@ QString DecorationBridge::readTheme() const void DecorationBridge::init() { + m_noPlugin = readNoPlugin(); + if (m_noPlugin) { + return; + } m_plugin = readPlugin(); m_settings = QSharedPointer::create(this); initPlugin(); @@ -118,6 +128,23 @@ static void recreateDecorations() void DecorationBridge::reconfigure() { + if (m_noPlugin != readNoPlugin()) { + m_noPlugin = !m_noPlugin; + // no plugin setting changed + if (m_noPlugin) { + // decorations disabled now + m_plugin = QString(); + delete m_factory; + m_factory = nullptr; + m_settings.clear(); + } else { + // decorations enabled now + init(); + } + recreateDecorations(); + return; + } + const QString newPlugin = readPlugin(); if (newPlugin != m_plugin) { // plugin changed, recreate everything @@ -200,6 +227,9 @@ void DecorationBridge::update(KDecoration2::Decoration *decoration, const QRect KDecoration2::Decoration *DecorationBridge::createDecoration(Client *client) { + if (m_noPlugin) { + return nullptr; + } if (!m_factory) { return nullptr; } diff --git a/decorations/decorationbridge.h b/decorations/decorationbridge.h index 6c78e9088c..269604bd7e 100644 --- a/decorations/decorationbridge.h +++ b/decorations/decorationbridge.h @@ -78,6 +78,7 @@ private: QString m_defaultTheme; QString m_theme; QSharedPointer m_settings; + bool m_noPlugin; KWIN_SINGLETON(DecorationBridge) }; } // Decoration