From 81782b38e41ad4d82cee060b1e3e39bc7d36e446 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 3 Apr 2024 13:07:55 +0300 Subject: [PATCH] Guard against calling set_size while applying a configure event more explicitly Depending on code path taken, geometry.size() == m_pendingSize can produce incorrect results. If a configure event is applied, it's fine. If the window is resized by user, m_pendingSize will have outdated value, and setWindowGeometry() can ignore future size updates that are valid. In hindsight, we need special hooks in the QWaylandWindow to request and apply new geometry. Rather than have one function that deals with all cases. (cherry picked from commit 127d817aa1b2de7d8beec6d1eabae49e4e50140e) --- src/qwaylandlayersurface.cpp | 7 ++++--- src/qwaylandlayersurface_p.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qwaylandlayersurface.cpp b/src/qwaylandlayersurface.cpp index f65c7eb..56b4e05 100644 --- a/src/qwaylandlayersurface.cpp +++ b/src/qwaylandlayersurface.cpp @@ -99,7 +99,7 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint if (!m_configured) { m_configured = true; - window()->resizeFromApplyConfigure(m_pendingSize); + applyConfigure(); sendExpose(); } else { // Later configures are resizes, so we have to queue them up for a time when we @@ -121,7 +121,9 @@ void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *po void QWaylandLayerSurface::applyConfigure() { + m_configuring = true; window()->resizeFromApplyConfigure(m_pendingSize); + m_configuring = false; } void QWaylandLayerSurface::setAnchor(uint anchor) @@ -160,8 +162,7 @@ void QWaylandLayerSurface::setLayer(uint32_t layer) void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry) { - // if we are setting it to the last size we were configured at, we don't need to do anything - if (geometry.size() == m_pendingSize && !m_waitForSyncCallback) { + if (m_configuring) { return; } diff --git a/src/qwaylandlayersurface_p.h b/src/qwaylandlayersurface_p.h index b4b1c06..ea66fcf 100644 --- a/src/qwaylandlayersurface_p.h +++ b/src/qwaylandlayersurface_p.h @@ -62,6 +62,7 @@ private: QString m_activationToken; bool m_configured = false; + bool m_configuring = false; static const wl_callback_listener syncCallbackListener; struct wl_callback *m_waitForSyncCallback = nullptr;