Add missing size check in Placement::placeOnScreenDisplay()

In order to center a window, kwin needs to know the window size.
This commit is contained in:
Vlad Zahorodnii 2024-08-22 21:08:01 +03:00
parent 6379b8b01a
commit 913a850584

View file

@ -487,9 +487,14 @@ void Placement::placeOnScreenDisplay(Window *c, const QRect &area)
{ {
Q_ASSERT(area.isValid()); Q_ASSERT(area.isValid());
const QSizeF size = c->size();
if (size.isEmpty()) {
return;
}
// place at lower area of the screen // place at lower area of the screen
const int x = area.left() + (area.width() - c->width()) / 2; const int x = area.left() + (area.width() - size.width()) / 2;
const int y = area.top() + 2 * area.height() / 3 - c->height() / 2; const int y = area.top() + 2 * area.height() / 3 - size.height() / 2;
c->move(QPoint(x, y)); c->move(QPoint(x, y));
} }