From e4da5002ae4e9d68cc4ac777ed77b4a225659440 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 1 Apr 2026 17:11:20 -0400 Subject: [PATCH] fix: a11y_ready state for sctk surfaces --- winit/src/lib.rs | 9 +++++++-- .../platform_specific/wayland/sctk_event.rs | 4 ++-- winit/src/window/state.rs | 18 ++++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 66cf7ff8..735d73aa 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -610,6 +610,11 @@ where #[cfg(feature = "a11y")] Control::InitAdapter(id, window) => { self.init_adapter(event_loop, id, window); + + self.process_event( + event_loop, + Some(Event::A11yAdapter(id)), + ); } #[cfg(feature = "a11y")] Control::Cleanup(id) => { @@ -1027,7 +1032,7 @@ async fn run_instance

( }; window.redraw_requested = false; - if !window.state.ready { + if !window.state.is_ready() { control_sender .start_send(Control::Winit( window.raw.id(), @@ -1910,7 +1915,7 @@ async fn run_instance

( #[cfg(feature = "a11y")] Event::A11yAdapter(window_id) => { if let Some(window) = window_manager.get_mut(window_id) { - window.state.ready = true; + window.state.set_a11y_ready(true); } } _ => {} diff --git a/winit/src/platform_specific/wayland/sctk_event.rs b/winit/src/platform_specific/wayland/sctk_event.rs index 04cad329..3a1a0166 100755 --- a/winit/src/platform_specific/wayland/sctk_event.rs +++ b/winit/src/platform_specific/wayland/sctk_event.rs @@ -1020,7 +1020,7 @@ impl SctkEvent { theme::Mode::None, // TODO do we really need to track the system theme here? 0, ); - window.state.ready = false; + window.state.set_ready(false); let logical_size = window.logical_size(); let mut ui = crate::build_user_interface( @@ -1097,7 +1097,7 @@ impl SctkEvent { .map(|v| (id.inner(), v)) }) { - w.state.ready = true; + w.state.set_ready(true); if first { control_sender .send(Control::Winit( diff --git a/winit/src/window/state.rs b/winit/src/window/state.rs index de8d7cfc..6fda1c7e 100644 --- a/winit/src/window/state.rs +++ b/winit/src/window/state.rs @@ -25,7 +25,8 @@ where theme_mode: theme::Mode, default_theme: P::Theme, style: theme::Style, - pub(crate) ready: bool, + ready: bool, + a11y_ready: bool, } impl Debug for State

@@ -83,10 +84,23 @@ where default_theme, style, - ready: cfg!(not(feature = "a11y")), + ready: true, + a11y_ready: !cfg!(not(feature = "a11y")), } } + pub(crate) fn is_ready(&self) -> bool { + self.ready && self.a11y_ready + } + + pub(crate) fn set_ready(&mut self, ready: bool) { + self.ready = ready; + } + + pub(crate) fn set_a11y_ready(&mut self, ready: bool) { + self.a11y_ready = ready; + } + pub fn viewport(&self) -> &Viewport { &self.viewport }