From e92342693041b3244abb7bdbc70affd900875b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 23 Aug 2013 13:07:52 +0200 Subject: [PATCH] Add a recreateDecorations signal to KDecorationFactory A factory is supposed to emit this signal whenever the decorations need to be recrated. The DecorationPlugins inside KWin Core connect to the signal and recreate the decorations. This signal is supposed to replace the reset method which encoded this information in the return value and which is already ignored. --- decorations.cpp | 20 ++++++++++++++++++++ decorations.h | 1 + libkdecorations/kdecorationfactory.h | 8 ++++++++ workspace.cpp | 10 ++-------- 4 files changed, 31 insertions(+), 8 deletions(-) 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)