diff --git a/geometry.cpp b/geometry.cpp
index 419106ee78..5a6786d189 100644
--- a/geometry.cpp
+++ b/geometry.cpp
@@ -2629,7 +2629,7 @@ void Client::finishMoveResize(bool cancel)
if (isElectricBorderMaximizing()) {
setQuickTileMode(electricMode);
electricMaximizing = false;
- workspace()->outline()->hide();
+ outline()->hide();
} else if (!cancel) {
if (!(maximizeMode() & MaximizeHorizontal)) {
geom_restore.setX(geometry().x());
@@ -3088,9 +3088,9 @@ void Client::setElectricBorderMaximizing(bool maximizing)
{
electricMaximizing = maximizing;
if (maximizing)
- workspace()->outline()->show(electricBorderMaximizeGeometry(cursorPos(), desktop()));
+ outline()->show(electricBorderMaximizeGeometry(cursorPos(), desktop()));
else
- workspace()->outline()->hide();
+ outline()->hide();
}
QRect Client::electricBorderMaximizeGeometry(QPoint pos, int desktop)
diff --git a/outline.cpp b/outline.cpp
index 88835ae113..ad3cfc01f6 100644
--- a/outline.cpp
+++ b/outline.cpp
@@ -33,6 +33,8 @@ along with this program. If not, see .
namespace KWin {
+KWIN_SINGLETON_FACTORY(Outline)
+
Outline::Outline(QObject *parent)
: QObject(parent)
, m_active(false)
diff --git a/outline.h b/outline.h
index 82e64300aa..bdb447a301 100644
--- a/outline.h
+++ b/outline.h
@@ -21,6 +21,7 @@ along with this program. If not, see .
#ifndef KWIN_OUTLINE_H
#define KWIN_OUTLINE_H
#include "xcbutils.h"
+#include
#include
namespace Plasma {
@@ -44,7 +45,6 @@ class OutlineVisual;
class Outline : public QObject {
Q_OBJECT
public:
- Outline(QObject *parent);
~Outline();
/**
@@ -87,6 +87,7 @@ private:
QScopedPointer m_visual;
QRect m_outlineGeometry;
bool m_active;
+ KWIN_SINGLETON(Outline)
};
class OutlineVisual
@@ -163,6 +164,12 @@ void NonCompositedOutlineVisual::forEachWindow(T method)
(m_leftOutline.*method)();
}
+inline
+Outline *outline()
+{
+ return Outline::self();
+}
+
}
#endif
diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp
index d64bb63166..2ef83c4723 100644
--- a/scripting/workspace_wrapper.cpp
+++ b/scripting/workspace_wrapper.cpp
@@ -242,17 +242,17 @@ void WorkspaceWrapper::setupClientConnections(KWin::Client *client)
void WorkspaceWrapper::showOutline(const QRect &geometry)
{
- Workspace::self()->outline()->show(geometry);
+ outline()->show(geometry);
}
void WorkspaceWrapper::showOutline(int x, int y, int width, int height)
{
- Workspace::self()->outline()->show(QRect(x, y, width, height));
+ outline()->show(QRect(x, y, width, height));
}
void WorkspaceWrapper::hideOutline()
{
- Workspace::self()->outline()->hide();
+ outline()->hide();
}
Client *WorkspaceWrapper::getClient(qulonglong windowId)
diff --git a/workspace.cpp b/workspace.cpp
index fc94d34ad6..8f32f61b7c 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -231,7 +231,7 @@ Workspace::Workspace(bool restore)
client_keys = new KActionCollection(this);
- m_outline = new Outline(this);
+ Outline::create(this);
initShortcuts();
@@ -1530,11 +1530,6 @@ void Workspace::slotBlockShortcuts(int data)
(*it)->updateMouseGrab();
}
-Outline* Workspace::outline()
-{
- return m_outline;
-}
-
QString Workspace::supportInformation() const
{
QString support;
diff --git a/workspace.h b/workspace.h
index 512117c285..4711448277 100644
--- a/workspace.h
+++ b/workspace.h
@@ -56,7 +56,6 @@ namespace KWin
class Client;
class KillWindow;
-class Outline;
class RootInfo;
class Rules;
class UserActionsMenu;
@@ -172,8 +171,6 @@ public:
return deleted;
}
- Outline* outline();
-
#ifdef KWIN_BUILD_SCREENEDGES
void stackScreenEdgesUnderOverrideRedirect();
#endif
@@ -182,7 +179,6 @@ public:
QPoint cascadeOffset(const Client *c) const;
private:
- Outline* m_outline;
Compositor *m_compositor;
//-------------------------------------------------