wasm: Don't clamp y position of child QWindows to parent rect

A child window should be possible to place at arbitrary positions
within its parent, even outside the parent's current rect. Once
the parent size is changed, the child might become visible.

The current code also caused issues when the parent did not
have a size yet (0x0) at the time of the child's setGeometry
call, resulting in the child always being placed at y=0.

Pick-to: 6.6
Change-Id: I1534b606ab6eb7d51216d3b305a1b60443c41ec2
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-08-08 15:35:51 +02:00
parent e73d0ffb4c
commit 89209c8eca

View File

@ -278,9 +278,12 @@ void QWasmWindow::setGeometry(const QRect &rect)
auto rectInViewport = QRect(containerGeometryInViewport.topLeft() + offset, rect.size());
QRect cappedGeometry(rectInViewport);
cappedGeometry.moveTop(
if (!parent()) {
// Clamp top level windows top position to the screen bounds
cappedGeometry.moveTop(
std::max(std::min(rectInViewport.y(), containerGeometryInViewport.bottom()),
containerGeometryInViewport.y() + margins.top()));
}
cappedGeometry.setSize(
cappedGeometry.size().expandedTo(windowMinimumSize()).boundedTo(windowMaximumSize()));
return QRect(QPoint(rect.x(), rect.y() + cappedGeometry.y() - rectInViewport.y()),