Commit 607e175b authored by Martin Flöser's avatar Martin Flöser
Browse files

Make Placement a Singleton

No real change as there has only been one Placement instance inside
Workspace anyway.
parent 7518da99
......@@ -39,6 +39,15 @@ namespace KWin
#ifndef KCMRULES
Placement *Placement::s_self = NULL;
Placement *Placement::create(Workspace *ws)
{
Q_ASSERT(!s_self);
s_self = new Placement(ws);
return s_self;
}
Placement::Placement(Workspace* w)
{
m_WorkspacePtr = w;
......@@ -46,6 +55,11 @@ Placement::Placement(Workspace* w)
reinitCascading(0);
}
Placement::~Placement()
{
s_self = NULL;
}
/*!
Places the client \a c according to the workspace's layout policy
*/
......
......@@ -36,8 +36,7 @@ class Client;
class Placement
{
public:
Placement(Workspace* w);
virtual ~Placement();
/**
* Placement policies. How workspace decides the way windows get positioned
......@@ -75,15 +74,24 @@ public:
static Policy policyFromString(const QString& policy, bool no_special);
static const char* policyToString(Policy policy);
/**
* Singleton getter for this Placement object once the Placement has been created.
* @see create
**/
static Placement *self();
/**
* Creates the Placement singleton.
**/
static Placement *create(Workspace *ws);
private:
explicit Placement(Workspace* w);
void place(Client* c, QRect& area, Policy policy, Policy nextPlacement = Unknown);
void placeUnderMouse(Client* c, QRect& area, Policy next = Unknown);
void placeOnMainWindow(Client* c, QRect& area, Policy next = Unknown);
QRect checkArea(const Client*c, const QRect& area);
Placement();
//CT needed for cascading+
struct DesktopCascadingInfo {
QPoint pos;
......@@ -94,8 +102,15 @@ private:
QList<DesktopCascadingInfo> cci;
Workspace* m_WorkspacePtr;
static Placement *s_self;
};
inline
Placement *Placement::self()
{
return s_self;
}
} // namespace
#endif
......@@ -374,7 +374,7 @@ void Workspace::init()
m_desktopFocusChain = m_activitiesDesktopFocusChain.insert(QString(), QVector<int>(numberOfDesktops()));
// Now we know how many desktops we'll have, thus we initialize the positioning object
initPositioning = new Placement(this);
initPositioning = Placement::create(this);
loadDesktopSettings();
updateDesktopLayout();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment