From 0de9b81a8c60e1078febdeec95abed1f16759f4f Mon Sep 17 00:00:00 2001 From: Lu YaNing Date: Thu, 15 May 2025 17:09:22 +0800 Subject: [PATCH] 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 --- .../shellintegration/xdg-shell/qwaylandxdgshell.cpp | 8 ++++++-- .../shellintegration/xdg-shell/qwaylandxdgshell_p.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 338d66ea19f..e6ef7767768 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -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() diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h index 12f52da5ea6..f7d223b51d0 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h @@ -161,6 +161,7 @@ private: QString m_activationToken; QString m_appId; bool m_alertState = false; + QRect m_lastGeometry; friend class QWaylandXdgShell; };