From fd978838ccb98da01b090bde6a4c22f05e52698c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 28 Oct 2022 00:50:28 +0300 Subject: [PATCH] qpa: Geometry handling fixes We don't need to emit {x,y,width,height}Changed signals ourselves. We also need to send an expose event otherwise the window can be rendered incorrectly if it's resized. The logic follows QtWayland implementation. --- src/plugins/qpa/window.cpp | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/plugins/qpa/window.cpp b/src/plugins/qpa/window.cpp index b8a1fe7b9c..d3ead70528 100644 --- a/src/plugins/qpa/window.cpp +++ b/src/plugins/qpa/window.cpp @@ -60,29 +60,22 @@ void Window::requestActivateWindow() void Window::setGeometry(const QRect &rect) { - const QRect &oldRect = geometry(); + const QRect oldGeometry = geometry(); QPlatformWindow::setGeometry(rect); - if (rect.x() != oldRect.x()) { - Q_EMIT window()->xChanged(rect.x()); - } - if (rect.y() != oldRect.y()) { - Q_EMIT window()->yChanged(rect.y()); - } - if (rect.width() != oldRect.width()) { - Q_EMIT window()->widthChanged(rect.width()); - } - if (rect.height() != oldRect.height()) { - Q_EMIT window()->heightChanged(rect.height()); - } - const QSize nativeSize = rect.size() * m_scale; - - if (m_contentFBO) { - if (m_contentFBO->size() != nativeSize) { - m_resized = true; + if (window()->isVisible() && rect.isValid()) { + const QSize nativeSize = rect.size() * m_scale; + if (m_contentFBO) { + if (m_contentFBO->size() != nativeSize) { + m_resized = true; + } } + QWindowSystemInterface::handleGeometryChange(window(), geometry()); + } + + if (isExposed() && oldGeometry.size() != rect.size()) { + QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), rect.size())); } - QWindowSystemInterface::handleGeometryChange(window(), geometry()); } WId Window::winId() const