Commit 0d704b89 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

placement: move singleton to Workspace

parent 3c56bd97
......@@ -344,7 +344,7 @@ void MoveResizeWindowTest::testPackTo()
QCOMPARE(window->frameGeometry(), QRect(0, 0, 100, 50));
// let's place it centered
Placement::self()->placeCentered(window, QRect(0, 0, 1280, 1024));
workspace()->placement()->placeCentered(window, QRect(0, 0, 1280, 1024));
QCOMPARE(window->frameGeometry(), QRect(590, 487, 100, 50));
QFETCH(QString, methodCall);
......@@ -394,7 +394,7 @@ void MoveResizeWindowTest::testPackAgainstClient()
QCOMPARE(workspace()->activeWindow(), window);
QCOMPARE(window->frameGeometry().size(), QSize(10, 10));
// let's place it centered
Placement::self()->placeCentered(window, QRect(0, 0, 1280, 1024));
workspace()->placement()->placeCentered(window, QRect(0, 0, 1280, 1024));
QCOMPARE(window->frameGeometry(), QRect(635, 507, 10, 10));
QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData());
QCOMPARE(window->frameGeometry(), expectedGeometry);
......@@ -413,7 +413,7 @@ void MoveResizeWindowTest::testPackAgainstClient()
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
// let's place it centered
Placement::self()->placeCentered(window, QRect(0, 0, 1280, 1024));
workspace()->placement()->placeCentered(window, QRect(0, 0, 1280, 1024));
QCOMPARE(window->frameGeometry(), QRect(590, 487, 100, 50));
QFETCH(QString, methodCall);
......@@ -463,7 +463,7 @@ void MoveResizeWindowTest::testGrowShrink()
QCOMPARE(workspace()->activeWindow(), window);
// let's place it centered
Placement::self()->placeCentered(window, QRect(0, 0, 1280, 1024));
workspace()->placement()->placeCentered(window, QRect(0, 0, 1280, 1024));
QCOMPARE(window->frameGeometry(), QRect(590, 487, 100, 50));
QFETCH(QString, methodCall);
......
......@@ -79,10 +79,10 @@ void DBusInterface::killWindow()
Workspace::self()->slotKillWindow();
}
#define WRAP(name) \
void DBusInterface::name() \
{ \
Placement::self()->name(); \
#define WRAP(name) \
void DBusInterface::name() \
{ \
workspace()->placement()->name(); \
}
WRAP(cascadeDesktop)
......
......@@ -28,18 +28,11 @@ namespace KWin
#ifndef KCMRULES
KWIN_SINGLETON_FACTORY(Placement)
Placement::Placement(QObject *)
Placement::Placement()
{
reinitCascading(0);
}
Placement::~Placement()
{
s_self = nullptr;
}
/**
* Places the client \a c according to the workspace's layout policy
*/
......
......@@ -28,7 +28,7 @@ class Window;
class KWIN_EXPORT Placement
{
public:
virtual ~Placement();
explicit Placement();
/**
* Placement policies. How workspace decides the way windows get positioned
......@@ -91,8 +91,6 @@ private:
};
QList<DesktopCascadingInfo> cci;
KWIN_SINGLETON(Placement)
};
} // namespace
......
......@@ -111,7 +111,7 @@ Window::Window()
Q_UNUSED(c)
if (isOnScreenDisplay() && !frameGeometry().isEmpty() && old.size() != frameGeometry().size() && isPlaceable()) {
GeometryUpdatesBlocker blocker(this);
Placement::self()->place(this, workspace()->clientArea(PlacementArea, this, workspace()->activeOutput()));
workspace()->placement()->place(this, workspace()->clientArea(PlacementArea, this, workspace()->activeOutput()));
}
});
......
......@@ -232,7 +232,7 @@ void Workspace::init()
vds->setConfig(config);
// Now we know how many desktops we'll have, thus we initialize the positioning object
Placement::create(this);
m_placement = std::make_unique<Placement>();
// positioning object needs to be created before the virtual desktops are loaded.
vds->load();
......@@ -490,7 +490,7 @@ Workspace::~Workspace()
delete RuleBook::self();
kwinApp()->config()->sync();
delete Placement::self();
m_placement.reset();
delete m_windowKeysDialog;
_self = nullptr;
......@@ -774,7 +774,7 @@ void Workspace::addWaylandWindow(Window *window)
placementDone = true;
}
if (!placementDone) {
Placement::self()->place(window, area);
m_placement->place(window, area);
}
}
m_allClients.append(window);
......@@ -1253,7 +1253,7 @@ void Workspace::slotOutputDisabled(Output *output)
void Workspace::slotDesktopAdded(VirtualDesktop *desktop)
{
m_focusChain->addDesktop(desktop);
Placement::self()->reinitCascading(0);
m_placement->reinitCascading(0);
updateClientArea();
}
......@@ -1271,7 +1271,7 @@ void Workspace::slotDesktopRemoved(VirtualDesktop *desktop)
}
updateClientArea();
Placement::self()->reinitCascading(0);
m_placement->reinitCascading(0);
m_focusChain->removeDesktop(desktop);
}
......@@ -1892,7 +1892,7 @@ void Workspace::addInternalWindow(InternalWindow *window)
if (window->isPlaceable()) {
const QRectF area = clientArea(PlacementArea, window, workspace()->activeOutput());
Placement::self()->place(window, area);
m_placement->place(window, area);
}
updateStackingOrder(true);
......@@ -2847,6 +2847,11 @@ Outline *Workspace::outline() const
return m_outline.get();
}
Placement *Workspace::placement() const
{
return m_placement.get();
}
#if KWIN_BUILD_ACTIVITIES
Activities *Workspace::activities() const
{
......
......@@ -438,6 +438,7 @@ public:
ApplicationMenu *applicationMenu() const;
Decoration::DecorationBridge *decorationBridge() const;
Outline *outline() const;
Placement *placement() const;
#if KWIN_BUILD_ACTIVITIES
Activities *activities() const;
#endif
......@@ -713,6 +714,7 @@ private:
std::unique_ptr<ApplicationMenu> m_applicationMenu;
std::unique_ptr<Decoration::DecorationBridge> m_decorationBridge;
std::unique_ptr<Outline> m_outline;
std::unique_ptr<Placement> m_placement;
#if KWIN_BUILD_ACTIVITIES
std::unique_ptr<Activities> m_activities;
#endif
......
......@@ -702,7 +702,7 @@ bool X11Window::manage(xcb_window_t w, bool isMapped)
}
if (!placementDone) {
// Placement needs to be after setting size
Placement::self()->place(this, area);
workspace()->placement()->place(this, area);
// The client may have been moved to another screen, update placement area.
area = workspace()->clientArea(PlacementArea, this);
dontKeepInArea = true;
......@@ -4416,7 +4416,7 @@ void X11Window::changeMaximize(bool horizontal, bool vertical, bool adjust)
if (geometryRestore().width() == 0 || !clientArea.contains(geometryRestore().center())) {
// needs placement
resize(constrainFrameSize(QSize(width() * 2 / 3, clientArea.height()), SizeModeFixedH));
Placement::self()->placeSmart(this, clientArea);
workspace()->placement()->placeSmart(this, clientArea);
} else {
moveResize(QRectF(QPointF(geometryRestore().x(), clientArea.top()),
constrainFrameSize(QSize(geometryRestore().width(), clientArea.height()), SizeModeFixedH)));
......@@ -4436,7 +4436,7 @@ void X11Window::changeMaximize(bool horizontal, bool vertical, bool adjust)
if (geometryRestore().height() == 0 || !clientArea.contains(geometryRestore().center())) {
// needs placement
resize(constrainFrameSize(QSize(clientArea.width(), height() * 2 / 3), SizeModeFixedW));
Placement::self()->placeSmart(this, clientArea);
workspace()->placement()->placeSmart(this, clientArea);
} else {
moveResize(QRectF(QPoint(clientArea.left(), geometryRestore().y()),
constrainFrameSize(QSize(clientArea.width(), geometryRestore().height()), SizeModeFixedW)));
......@@ -4471,7 +4471,7 @@ void X11Window::changeMaximize(bool horizontal, bool vertical, bool adjust)
s.setHeight(geometryRestore().height());
}
resize(constrainFrameSize(s));
Placement::self()->placeSmart(this, clientArea);
workspace()->placement()->placeSmart(this, clientArea);
restore = frameGeometry();
if (geometryRestore().width() > 0) {
restore.moveLeft(geometryRestore().x());
......@@ -4486,7 +4486,7 @@ void X11Window::changeMaximize(bool horizontal, bool vertical, bool adjust)
}
moveResize(restore);
if (!clientArea.contains(geometryRestore().center())) { // Not restoring to the same screen
Placement::self()->place(this, clientArea);
workspace()->placement()->place(this, clientArea);
}
info->setState(NET::States(), NET::Max);
updateQuickTileMode(QuickTileFlag::None);
......
......@@ -1409,7 +1409,7 @@ void XdgToplevelWindow::initialize()
}
if (needsPlacement) {
const QRectF area = workspace()->clientArea(PlacementArea, this, workspace()->activeOutput());
Placement::self()->place(this, area);
workspace()->placement()->place(this, area);
}
configureDecoration();
......@@ -1806,7 +1806,7 @@ void XdgPopupWindow::handleRepositionRequested(quint32 token)
void XdgPopupWindow::relayout()
{
Placement::self()->place(this, QRect());
workspace()->placement()->place(this, QRect());
scheduleConfigure();
}
......@@ -2029,7 +2029,7 @@ void XdgPopupWindow::initialize()
updateReactive();
const QRectF area = workspace()->clientArea(PlacementArea, this, workspace()->activeOutput());
Placement::self()->place(this, area);
workspace()->placement()->place(this, area);
scheduleConfigure();
}
......
Supports Markdown
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