Port Workspace::cascadeOffset() away from Window::frameGeometry()
Workspace::cascadeOffset() can be called by placement code before the frame geometry has a valid position. That is wrong. In order to avoid that, use the placement area that we are given.
This commit is contained in:
parent
428c4c4fd1
commit
4258797402
3 changed files with 8 additions and 9 deletions
|
@ -310,14 +310,14 @@ void TestPlacement::testPlaceZeroCornered()
|
|||
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
|
||||
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(window2);
|
||||
QCOMPARE(window2->pos(), window1->pos() + workspace()->cascadeOffset(window2));
|
||||
QCOMPARE(window2->pos(), window1->pos() + workspace()->cascadeOffset(workspace()->clientArea(PlacementArea, window2)));
|
||||
QCOMPARE(window2->size(), QSize(100, 50));
|
||||
|
||||
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
|
||||
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
|
||||
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::green);
|
||||
QVERIFY(window3);
|
||||
QCOMPARE(window3->pos(), window2->pos() + workspace()->cascadeOffset(window3));
|
||||
QCOMPARE(window3->pos(), window2->pos() + workspace()->cascadeOffset(workspace()->clientArea(PlacementArea, window3)));
|
||||
QCOMPARE(window3->size(), QSize(100, 50));
|
||||
|
||||
shellSurface3.reset();
|
||||
|
@ -421,7 +421,7 @@ void TestPlacement::testCascadeIfCovering()
|
|||
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
|
||||
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(window2);
|
||||
QCOMPARE(window2->pos(), window1->pos() + workspace()->cascadeOffset(window2));
|
||||
QCOMPARE(window2->pos(), window1->pos() + workspace()->cascadeOffset(workspace()->clientArea(PlacementArea, window2)));
|
||||
QCOMPARE(window2->size(), QSize(100, 50));
|
||||
|
||||
// window should be cascaded to avoid overlapping window 1 and 2
|
||||
|
@ -429,7 +429,7 @@ void TestPlacement::testCascadeIfCovering()
|
|||
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
|
||||
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::green);
|
||||
QVERIFY(window3);
|
||||
QCOMPARE(window3->pos(), window2->pos() + workspace()->cascadeOffset(window3));
|
||||
QCOMPARE(window3->pos(), window2->pos() + workspace()->cascadeOffset(workspace()->clientArea(PlacementArea, window3)));
|
||||
QCOMPARE(window3->size(), QSize(100, 50));
|
||||
|
||||
shellSurface3.reset();
|
||||
|
|
|
@ -361,9 +361,8 @@ void Placement::reinitCascading(VirtualDesktop *desktop)
|
|||
};
|
||||
}
|
||||
|
||||
QPoint Workspace::cascadeOffset(const Window *c) const
|
||||
QPoint Workspace::cascadeOffset(const QRectF &area) const
|
||||
{
|
||||
QRect area = clientArea(PlacementArea, c, c->frameGeometry().center()).toRect();
|
||||
return QPoint(area.width() / 48, area.height() / 48);
|
||||
}
|
||||
|
||||
|
@ -379,7 +378,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 QPoint delta = workspace()->cascadeOffset(area);
|
||||
|
||||
VirtualDesktop *dn = c->isOnCurrentDesktop() ? VirtualDesktopManager::self()->currentDesktop() : c->desktops().constLast();
|
||||
|
||||
|
@ -581,7 +580,7 @@ void Placement::placeMaximizing(Window *c, const QRect &area, PlacementPolicy ne
|
|||
*/
|
||||
void Placement::cascadeIfCovering(Window *window, const QRectF &area)
|
||||
{
|
||||
const QPoint offset = workspace()->cascadeOffset(window);
|
||||
const QPoint offset = workspace()->cascadeOffset(area);
|
||||
|
||||
VirtualDesktop *const desktop = window->isOnCurrentDesktop() ? VirtualDesktopManager::self()->currentDesktop() : window->desktops().front();
|
||||
|
||||
|
|
|
@ -265,7 +265,7 @@ public:
|
|||
TileManager *tileManager(Output *output);
|
||||
|
||||
public:
|
||||
QPoint cascadeOffset(const Window *c) const;
|
||||
QPoint cascadeOffset(const QRectF &area) const;
|
||||
|
||||
private:
|
||||
QTimer *m_quickTileCombineTimer;
|
||||
|
|
Loading…
Reference in a new issue