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)
|
||||
{
|
||||
QRect r = rect;
|
||||
if (m_needsCompositor) {
|
||||
int yMin = window()->geometry().top() - window()->frameGeometry().top();
|
||||
const QRect clientAreaRect = ([this, &rect]() {
|
||||
if (!m_needsCompositor)
|
||||
return rect;
|
||||
|
||||
if (r.y() < yMin)
|
||||
r.moveTop(yMin);
|
||||
}
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user