diff --git a/src/placement.cpp b/src/placement.cpp index a51e93e10b..d63096f420 100644 --- a/src/placement.cpp +++ b/src/placement.cpp @@ -31,7 +31,7 @@ namespace KWin Placement::Placement() { - reinitCascading(0); + reinitCascading(); } /** @@ -335,24 +335,24 @@ void Placement::placeSmart(Window *window, const QRectF &area, PlacementPolicy / window->move(QPoint(x_optimal, y_optimal)); } -void Placement::reinitCascading(int desktop) +void Placement::reinitCascading() { - // desktop == 0 - reinit all - if (desktop == 0) { - cci.clear(); - for (uint i = 0; i < VirtualDesktopManager::self()->count(); ++i) { - DesktopCascadingInfo inf; - inf.pos = QPoint(-1, -1); - inf.col = 0; - inf.row = 0; - cci.append(inf); - } - } else { - cci[desktop - 1].pos = QPoint(-1, -1); - cci[desktop - 1].col = cci[desktop - 1].row = 0; + cci.clear(); + const auto desktops = VirtualDesktopManager::self()->desktops(); + for (VirtualDesktop *desktop : desktops) { + reinitCascading(desktop); } } +void Placement::reinitCascading(VirtualDesktop *desktop) +{ + cci[desktop] = DesktopCascadingInfo{ + .pos = QPoint(-1, -1), + .col = 0, + .row = 0, + }; +} + QPoint Workspace::cascadeOffset(const Window *c) const { QRect area = clientArea(PlacementArea, c, c->frameGeometry().center()).toRect(); @@ -373,7 +373,7 @@ void Placement::placeCascaded(Window *c, const QRect &area, PlacementPolicy next // CT how do I get from the 'Client' class the size that NW squarish "handle" const QPoint delta = workspace()->cascadeOffset(c); - const int dn = c->desktop() == 0 || c->isOnAllDesktops() ? (VirtualDesktopManager::self()->current() - 1) : (c->desktop() - 1); + VirtualDesktop *dn = c->isOnCurrentDesktop() ? VirtualDesktopManager::self()->currentDesktop() : c->desktops().constLast(); if (nextPlacement == PlacementUnknown) { nextPlacement = PlacementSmart; @@ -630,8 +630,7 @@ void Placement::cascadeIfCovering(Window *window, const QRectF &area) void Placement::cascadeDesktop() { Workspace *ws = Workspace::self(); - const int desktop = VirtualDesktopManager::self()->current(); - reinitCascading(desktop); + reinitCascading(VirtualDesktopManager::self()->currentDesktop()); const auto stackingOrder = ws->stackingOrder(); for (Window *window : stackingOrder) { if (!window->isClient() || (!window->isOnCurrentDesktop()) || (window->isMinimized()) || (window->isOnAllDesktops()) || (!window->isMovable())) { diff --git a/src/placement.h b/src/placement.h index f3d4320fa1..ee71fe6fec 100644 --- a/src/placement.h +++ b/src/placement.h @@ -22,6 +22,7 @@ class QObject; namespace KWin { +class VirtualDesktop; class Window; class KWIN_EXPORT Placement @@ -34,7 +35,8 @@ public: void placeCentered(Window *c, const QRectF &area, PlacementPolicy next = PlacementUnknown); - void reinitCascading(int desktop); + void reinitCascading(); + void reinitCascading(VirtualDesktop *desktop); void cascadeIfCovering(Window *c, const QRectF &area); @@ -71,7 +73,7 @@ private: int row; }; - QList cci; + QHash cci; }; } // namespace diff --git a/src/workspace.cpp b/src/workspace.cpp index 891000ce94..2708ae7004 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -1384,7 +1384,7 @@ void Workspace::updateOutputs(const QVector &outputOrder) void Workspace::slotDesktopAdded(VirtualDesktop *desktop) { m_focusChain->addDesktop(desktop); - m_placement->reinitCascading(0); + m_placement->reinitCascading(); updateClientArea(); } @@ -1409,7 +1409,7 @@ void Workspace::slotDesktopRemoved(VirtualDesktop *desktop) } updateClientArea(); - m_placement->reinitCascading(0); + m_placement->reinitCascading(); m_focusChain->removeDesktop(desktop); }