Client: Optimize set_window_geometry calls by caching last geometry

When a QtWayland client window is initialized or resized, set_window_geometry
may be called multiple times with the same geometry, resulting in redundant
protocol messages to the compositor.

According to: 904a00fc9e8e0547dce3f70b5b205f6c70cfd414

Fixes: QTBUG-136723
Change-Id: I2e993e2b185f30d57503b5a3ce7ab63ba46afec2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
Lu YaNing 2025-05-15 17:09:22 +08:00
parent c9ab69d4e3
commit 0de9b81a8c
2 changed files with 7 additions and 2 deletions

View File

@ -435,6 +435,7 @@ void QWaylandXdgSurface::applyConfigure()
if (m_popup)
m_popup->applyConfigure();
setContentGeometry(window()->windowContentGeometry());
window()->updateExposure();
}
@ -450,8 +451,11 @@ void QWaylandXdgSurface::propagateSizeHints()
void QWaylandXdgSurface::setContentGeometry(const QRect &rect)
{
if (window()->isExposed())
set_window_geometry(rect.x(), rect.y(), rect.width(), rect.height());
if (!window()->isExposed() || m_lastGeometry == rect)
return;
set_window_geometry(rect.x(), rect.y(), rect.width(), rect.height());
m_lastGeometry = rect;
}
void QWaylandXdgSurface::setSizeHints()

View File

@ -161,6 +161,7 @@ private:
QString m_activationToken;
QString m_appId;
bool m_alertState = false;
QRect m_lastGeometry;
friend class QWaylandXdgShell;
};