summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2022-09-07 16:21:43 +0200
committerMikolaj Boc <mikolaj.boc@qt.io>2022-09-08 21:12:52 +0200
commit522a93e303932e1c5ce7bc558d98c549589da17a (patch)
treea572812c31ab08470356efad1d899429397f80ae
parent809ff675c9492a5ddda82483aef9afb285383827 (diff)
Lock the window's caption area vertically inside its screen
The current code that locks the window does not take into account screens that don't start at non-zero y coordinate, nor does it cap the bottom of the window. Task-number: QTBUG-106031 Pick-to: 6.4 Change-Id: Ic22c016d32dca9d288a2a56c51ccde78144b436e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r--src/plugins/platforms/wasm/qwasmwindow.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp
index 700a7ef75a..c72e59c7ca 100644
--- a/src/plugins/platforms/wasm/qwasmwindow.cpp
+++ b/src/plugins/platforms/wasm/qwasmwindow.cpp
@@ -134,20 +134,25 @@ QWasmScreen *QWasmWindow::platformScreen() const
void QWasmWindow::setGeometry(const QRect &rect)
{
- QRect r = rect;
- if (m_needsCompositor) {
- int yMin = window()->geometry().top() - window()->frameGeometry().top();
-
- if (r.y() < yMin)
- r.moveTop(yMin);
- }
+ const QRect clientAreaRect = ([this, &rect]() {
+ if (!m_needsCompositor)
+ return rect;
+
+ const int captionHeight = window()->geometry().top() - window()->frameGeometry().top();
+ const auto screenGeometry = screen()->geometry();
+
+ QRect result(rect);
+ result.moveTop(std::max(std::min(rect.y(), screenGeometry.bottom()),
+ screenGeometry.y() + captionHeight));
+ return result;
+ })();
bool shouldInvalidate = true;
if (!m_windowState.testFlag(Qt::WindowFullScreen)
&& !m_windowState.testFlag(Qt::WindowMaximized)) {
- shouldInvalidate = m_normalGeometry.size() != r.size();
- m_normalGeometry = r;
+ shouldInvalidate = m_normalGeometry.size() != clientAreaRect.size();
+ m_normalGeometry = clientAreaRect;
}
- QWindowSystemInterface::handleGeometryChange(window(), r);
+ QWindowSystemInterface::handleGeometryChange(window(), clientAreaRect);
if (shouldInvalidate)
invalidate();
else