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>
This commit is contained in:
parent
809ff675c9
commit
522a93e303
@ -134,20 +134,25 @@ QWasmScreen *QWasmWindow::platformScreen() const
|
|||||||
|
|
||||||
void QWasmWindow::setGeometry(const QRect &rect)
|
void QWasmWindow::setGeometry(const QRect &rect)
|
||||||
{
|
{
|
||||||
QRect r = rect;
|
const QRect clientAreaRect = ([this, &rect]() {
|
||||||
if (m_needsCompositor) {
|
if (!m_needsCompositor)
|
||||||
int yMin = window()->geometry().top() - window()->frameGeometry().top();
|
return rect;
|
||||||
|
|
||||||
if (r.y() < yMin)
|
const int captionHeight = window()->geometry().top() - window()->frameGeometry().top();
|
||||||
r.moveTop(yMin);
|
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;
|
bool shouldInvalidate = true;
|
||||||
if (!m_windowState.testFlag(Qt::WindowFullScreen)
|
if (!m_windowState.testFlag(Qt::WindowFullScreen)
|
||||||
&& !m_windowState.testFlag(Qt::WindowMaximized)) {
|
&& !m_windowState.testFlag(Qt::WindowMaximized)) {
|
||||||
shouldInvalidate = m_normalGeometry.size() != r.size();
|
shouldInvalidate = m_normalGeometry.size() != clientAreaRect.size();
|
||||||
m_normalGeometry = r;
|
m_normalGeometry = clientAreaRect;
|
||||||
}
|
}
|
||||||
QWindowSystemInterface::handleGeometryChange(window(), r);
|
QWindowSystemInterface::handleGeometryChange(window(), clientAreaRect);
|
||||||
if (shouldInvalidate)
|
if (shouldInvalidate)
|
||||||
invalidate();
|
invalidate();
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user