Clean up Placement::placeCascaded()

Avoid using Window::frameGeometry() because its position is invalid.

In the future, the XdgToplevelWindow would need to run the placement
code before updating the Window::frameGeometry(). In order to prepare
for that, this change also makes placeCascaded() pull the window size
from a cached QSizeF() object.
This commit is contained in:
Vlad Zahorodnii 2024-08-22 20:41:28 +03:00
parent 3810811730
commit 646f071291

View file

@ -379,7 +379,8 @@ void Placement::placeCascaded(Window *c, const QRect &area, PlacementPolicy next
{ {
Q_ASSERT(area.isValid()); Q_ASSERT(area.isValid());
if (!c->frameGeometry().isValid()) { const QSizeF size = c->size();
if (size.isEmpty()) {
return; return;
} }
@ -402,11 +403,11 @@ void Placement::placeCascaded(Window *c, const QRect &area, PlacementPolicy next
int yp = cci[dn].pos.y(); int yp = cci[dn].pos.y();
// here to touch in case people vote for resize on placement // here to touch in case people vote for resize on placement
if ((yp + c->height()) > area.height()) { if ((yp + size.height()) > area.height()) {
yp = area.top(); yp = area.top();
} }
if ((xp + c->width()) > area.width()) { if ((xp + size.width()) > area.width()) {
if (!yp) { if (!yp) {
place(c, area, nextPlacement); place(c, area, nextPlacement);
return; return;
@ -427,7 +428,7 @@ void Placement::placeCascaded(Window *c, const QRect &area, PlacementPolicy next
} }
// last resort: if still doesn't fit, smart place it // last resort: if still doesn't fit, smart place it
if (((xp + c->width()) > area.width() - area.left()) || ((yp + c->height()) > area.height() - area.top())) { if (((xp + size.width()) > area.width() - area.left()) || ((yp + size.height()) > area.height() - area.top())) {
place(c, area, nextPlacement); place(c, area, nextPlacement);
return; return;
} }