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.

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>
(cherry picked from commit 89209c8eca985c290f8afec3e1aa8fd3426cda65)
This commit is contained in:
Tor Arne Vestbø 2023-08-08 15:35:51 +02:00
parent b4e7e6cfa7
commit 001394acf7

View File

@ -269,8 +269,11 @@ void QWasmWindow::setGeometry(const QRect &rect)
const auto screenGeometry = screen()->geometry();
QRect result(rect);
result.moveTop(std::max(std::min(rect.y(), screenGeometry.bottom()),
if (!parent()) {
// Clamp top level windows top position to the screen bounds
result.moveTop(std::max(std::min(rect.y(), screenGeometry.bottom()),
screenGeometry.y() + margins.top()));
}
result.setSize(
result.size().expandedTo(windowMinimumSize()).boundedTo(windowMaximumSize()));
return result;