diff --git a/decorations.cpp b/decorations.cpp index 24f4626e3f..70948fbae1 100644 --- a/decorations.cpp +++ b/decorations.cpp @@ -21,6 +21,8 @@ along with this program. If not, see . #include "decorations.h" #include "config-kwin.h" +#include "client.h" +#include "workspace.h" #include #include @@ -43,6 +45,7 @@ DecorationPlugin::DecorationPlugin(QObject *parent) #endif #ifdef KWIN_BUILD_DECORATIONS loadPlugin(QString()); // load the plugin specified in cfg file + connect(factory(), &KDecorationFactory::recreateDecorations, this, &DecorationPlugin::recreateDecorations); #else setDisabled(true); #endif @@ -170,4 +173,21 @@ QString DecorationPlugin::supportInformation() return support; } +void DecorationPlugin::recreateDecorations() +{ + if (m_disabled) { + return; + } + // Decorations need to be recreated + workspace()->forEachClient([](Client *c) { + c->updateDecoration(true, true); + }); + // If the new decoration doesn't supports tabs then ungroup clients + if (!supportsTabbing()) { + workspace()->forEachClient([](Client *c) { + c->untab(); + }); + } +} + } // namespace diff --git a/decorations.h b/decorations.h index fd934effd9..0534ebec14 100644 --- a/decorations.h +++ b/decorations.h @@ -52,6 +52,7 @@ public: public Q_SLOTS: void resetCompositing(); + void recreateDecorations(); protected: virtual void error(const QString& error_msg); private: diff --git a/libkdecorations/kdecorationfactory.h b/libkdecorations/kdecorationfactory.h index d5d8f64b15..31d8d518b6 100644 --- a/libkdecorations/kdecorationfactory.h +++ b/libkdecorations/kdecorationfactory.h @@ -107,6 +107,14 @@ public: * @internal */ void removeDecoration(KDecoration*); + +Q_SIGNALS: + /** + * @brief An implementing class should emit this signal if it's decorations should + * be recreated. For example after a setting changed in a way that the only logical + * step is to recreate the decoration. + */ + void recreateDecorations(); protected: /** * Constructor. Called after loading the decoration plugin. All global diff --git a/workspace.cpp b/workspace.cpp index fde64a0ee4..28f1c3cb29 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -812,15 +812,9 @@ void Workspace::slotReconfigure() DecorationPlugin *deco = DecorationPlugin::self(); if (!deco->isDisabled() && deco->reset()) { - // Decorations need to be recreated - for (ClientList::ConstIterator it = clients.constBegin(); it != clients.constEnd(); ++it) - (*it)->updateDecoration(true, true); - // If the new decoration doesn't supports tabs then ungroup clients - if (!decorationPlugin()->supportsTabbing()) { - foreach (Client * c, clients) - c->untab(); - } + deco->recreateDecorations(); deco->destroyPreviousPlugin(); + connect(deco->factory(), &KDecorationFactory::recreateDecorations, deco, &DecorationPlugin::recreateDecorations); } else { forEachClient(CheckBorderSizesProcedure()); foreach (Client * c, clients)