fix: a11y_ready state for sctk surfaces

This commit is contained in:
Ashley Wulber 2026-04-01 17:11:20 -04:00 committed by Ashley Wulber
parent 04c273a79b
commit e4da5002ae
3 changed files with 25 additions and 6 deletions

View file

@ -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<P>(
};
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<P>(
#[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);
}
}
_ => {}

View file

@ -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(

View file

@ -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<P: Program> Debug for State<P>
@ -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
}