From 1fb7e08f231621b475de018efdf9ac8ab5c0ba5f Mon Sep 17 00:00:00 2001 From: Frederic Laing Date: Tue, 18 Nov 2025 12:03:09 +0100 Subject: [PATCH] fix Wayland layer-shell protocol violation: "must ack the initial configure before attaching buffer" --- .../platform_specific/wayland/event_loop/state.rs | 1 - .../wayland/handlers/shell/layer.rs | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/winit/src/platform_specific/wayland/event_loop/state.rs b/winit/src/platform_specific/wayland/event_loop/state.rs index 688a021d..b722c79c 100644 --- a/winit/src/platform_specific/wayland/event_loop/state.rs +++ b/winit/src/platform_specific/wayland/event_loop/state.rs @@ -1054,7 +1054,6 @@ impl SctkState { if let Ok((id, surface, common)) = self.get_layer_surface(builder) { // TODO Ashley: all surfaces should probably have an optional title for a11y if nothing else let wl_surface = surface.wl_surface().clone(); - receive_frame(&mut self.frame_status, &wl_surface); send_event(&self.events_sender, &self.proxy, SctkEvent::LayerSurfaceEvent { variant: LayerSurfaceEventVariant::Created(self.queue_handle.clone(), surface, id, common, self.connection.display(), title), diff --git a/winit/src/platform_specific/wayland/handlers/shell/layer.rs b/winit/src/platform_specific/wayland/handlers/shell/layer.rs index 174127ee..65e5724b 100644 --- a/winit/src/platform_specific/wayland/handlers/shell/layer.rs +++ b/winit/src/platform_specific/wayland/handlers/shell/layer.rs @@ -1,5 +1,5 @@ use crate::platform_specific::wayland::{ - event_loop::state::SctkState, + event_loop::state::{receive_frame, SctkState}, sctk_event::{LayerSurfaceEventVariant, SctkEvent}, }; use cctk::sctk::{ @@ -42,7 +42,6 @@ impl LayerShellHandler for SctkState { mut configure: cctk::sctk::shell::wlr_layer::LayerSurfaceConfigure, _serial: u32, ) { - self.request_redraw(layer.wl_surface()); let layer = match self.layer_surfaces.iter_mut().find(|s| { s.surface.wl_surface().id() == layer.wl_surface().id() @@ -50,6 +49,7 @@ impl LayerShellHandler for SctkState { Some(l) => l, None => return, }; + let first = layer.last_configure.is_none(); let common = layer.common.lock().unwrap(); let requested_size = common.requested_size; drop(common); @@ -65,18 +65,22 @@ impl LayerShellHandler for SctkState { }; layer.update_viewport(configure.new_size.0, configure.new_size.1); - let first = layer.last_configure.is_none(); _ = layer.last_configure.replace(configure.clone()); let mut common = layer.common.lock().unwrap(); common.size = LogicalSize::new(configure.new_size.0, configure.new_size.1); + drop(common); + let wl_surface = layer.surface.wl_surface().clone(); + receive_frame(&mut self.frame_status, &wl_surface); + self.request_redraw(&wl_surface); + self.sctk_events.push(SctkEvent::LayerSurfaceEvent { variant: LayerSurfaceEventVariant::Configure( configure, - layer.surface.wl_surface().clone(), + wl_surface.clone(), first, ), - id: layer.surface.wl_surface().clone(), + id: wl_surface, }); } }