From 89209c8eca985c290f8afec3e1aa8fd3426cda65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 8 Aug 2023 15:35:51 +0200 Subject: [PATCH] wasm: Don't clamp y position of child QWindows to parent rect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Morten Johan Sørvig Reviewed-by: Piotr Wierciński --- src/plugins/platforms/wasm/qwasmwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index 21800e3b0b..4a92ba7a55 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -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()),