Make DeocrationPlugin a KWin singleton

Like so many other classes there is exactly one instance hold by
Workspace.
This commit is contained in:
Martin Gräßlin 2013-04-08 11:05:42 +02:00
parent 32be37bce3
commit 724bfd4548
3 changed files with 13 additions and 4 deletions

View file

@ -30,7 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
DecorationPlugin::DecorationPlugin() KWIN_SINGLETON_FACTORY(DecorationPlugin)
DecorationPlugin::DecorationPlugin(QObject *)
: KDecorationPlugins(KGlobal::config()) : KDecorationPlugins(KGlobal::config())
, m_noDecoration(false) , m_noDecoration(false)
{ {
@ -45,6 +47,11 @@ DecorationPlugin::DecorationPlugin()
#endif #endif
} }
DecorationPlugin::~DecorationPlugin()
{
s_self = NULL;
}
void DecorationPlugin::error(const QString &error_msg) void DecorationPlugin::error(const QString &error_msg)
{ {
qWarning("%s", QString(i18n("KWin: ") + error_msg).toLocal8Bit().data()); qWarning("%s", QString(i18n("KWin: ") + error_msg).toLocal8Bit().data());

View file

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KWIN_PLUGINS_H #define KWIN_PLUGINS_H
#include <kdecoration_plugins_p.h> #include <kdecoration_plugins_p.h>
#include <kwinglobals.h>
namespace KWin namespace KWin
{ {
@ -31,7 +32,7 @@ class DecorationPlugin
: public KDecorationPlugins : public KDecorationPlugins
{ {
public: public:
DecorationPlugin(); virtual ~DecorationPlugin();
virtual bool provides(Requirement); virtual bool provides(Requirement);
/** /**
* @returns @c true if there is no decoration plugin. * @returns @c true if there is no decoration plugin.
@ -42,6 +43,7 @@ protected:
private: private:
void setNoDecoration(bool noDecoration); void setNoDecoration(bool noDecoration);
bool m_noDecoration; bool m_noDecoration;
KWIN_SINGLETON(DecorationPlugin)
}; };
} // namespace } // namespace

View file

@ -159,7 +159,7 @@ Workspace::Workspace(bool restore)
reparseConfigFuture.waitForFinished(); reparseConfigFuture.waitForFinished();
options->loadConfig(); options->loadConfig();
options->loadCompositingConfig(false); options->loadCompositingConfig(false);
mgr = new DecorationPlugin; mgr = DecorationPlugin::create(this);
default_colormap = DefaultColormap(display(), screen_number); default_colormap = DefaultColormap(display(), screen_number);
installed_colormap = default_colormap; installed_colormap = default_colormap;
@ -534,7 +534,7 @@ Workspace::~Workspace()
delete rootInfo; delete rootInfo;
delete supportWindow; delete supportWindow;
delete mgr; delete DecorationManager::self();
delete startup; delete startup;
delete Placement::self(); delete Placement::self();
delete client_keys_dialog; delete client_keys_dialog;