Clean up Placement::placeSmart()

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 placeSmart() pull the window size from
a cached QSizeF() object.
This commit is contained in:
Vlad Zahorodnii 2024-08-22 20:49:24 +03:00
parent 646f071291
commit 6379b8b01a

View file

@ -178,7 +178,8 @@ void Placement::placeSmart(Window *window, const QRectF &area, PlacementPolicy /
* with ideas from xfce. * with ideas from xfce.
*/ */
if (!window->frameGeometry().isValid()) { const QSizeF size = window->size();
if (size.isEmpty()) {
return; return;
} }
@ -199,8 +200,8 @@ void Placement::placeSmart(Window *window, const QRectF &area, PlacementPolicy /
y_optimal = y; y_optimal = y;
// client gabarit // client gabarit
int ch = std::ceil(window->height()); int ch = std::ceil(size.height());
int cw = std::ceil(window->width()); int cw = std::ceil(size.width());
// Explicitly converts those to int to avoid accidentally // Explicitly converts those to int to avoid accidentally
// mixing ints and qreal in the calculations below. // mixing ints and qreal in the calculations below.