[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
This commit is contained in:
parent
1274740f51
commit
a002442224
2 changed files with 31 additions and 0 deletions
|
@ -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<KDecoration2::DecorationSettings>::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;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ private:
|
|||
QString m_defaultTheme;
|
||||
QString m_theme;
|
||||
QSharedPointer<KDecoration2::DecorationSettings> m_settings;
|
||||
bool m_noPlugin;
|
||||
KWIN_SINGLETON(DecorationBridge)
|
||||
};
|
||||
} // Decoration
|
||||
|
|
Loading…
Reference in a new issue