From 4727a2a032483274a3b09f12e86c9f60bc37a010 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Fri, 23 Aug 2024 09:57:09 +0000 Subject: [PATCH] Fix LayerShellV1 flicker (#3505) closes #3450 We now ignore all LayerShellV1 configure requests except the most recent one. --- .../frontend_wayland/layer_shell_v1.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/server/frontend_wayland/layer_shell_v1.cpp b/src/server/frontend_wayland/layer_shell_v1.cpp index e64dc709015..2b6ca3b0a02 100644 --- a/src/server/frontend_wayland/layer_shell_v1.cpp +++ b/src/server/frontend_wayland/layer_shell_v1.cpp @@ -585,19 +585,26 @@ void mf::LayerSurfaceV1::get_popup(struct wl_resource* popup) void mf::LayerSurfaceV1::ack_configure(uint32_t serial) { - while (!inflight_configures.empty() && inflight_configures.front().first < serial) - { - inflight_configures.pop_front(); - } + auto const acked_event = std::find_if( + std::begin(inflight_configures), + std::end(inflight_configures), + [serial](auto& p) { return p.first == serial; }); - if (inflight_configures.empty() || inflight_configures.front().first != serial) + if (acked_event == std::end(inflight_configures)) { BOOST_THROW_EXCEPTION(std::runtime_error( "Could not find acked configure with serial " + std::to_string(serial))); } - auto const acked_configure_size = inflight_configures.front().second; - inflight_configures.pop_front(); + auto const acked_configure_size = acked_event->second; + + inflight_configures.erase(std::begin(inflight_configures), std::next(acked_event)); + + if (!inflight_configures.empty()) + { + // If a stale configure has been acked, we do no more + return; + } client_size.set_pending(geom::Size{ acked_configure_size.width.value_or(client_size.pending().width),