fix: ensure adapter is created before window is marked visible

This commit is contained in:
Ashley Wulber 2026-03-30 15:45:23 -04:00 • committed by Ashley Wulber
parent 5fa8b72a21
commit d4b0c0482b

View file

@ -501,18 +501,26 @@ where
} }
}; };
} }
let window: Arc<dyn winit::window::Window + 'static> = Arc::from(window);
#[cfg(feature = "a11y")]
self.init_adapter(event_loop, id, window.clone());
self.process_event( self.process_event(
event_loop, event_loop,
Some(Event::WindowCreated { Some(Event::WindowCreated {
id, id,
window: Arc::from(window), window,
exit_on_close_request, exit_on_close_request,
make_visible: visible, make_visible: visible,
on_open, on_open,
resize_border, resize_border,
}), }),
); );
#[cfg(feature = "a11y")]
self.process_event(
event_loop,
Some(Event::A11yAdapter(id)),
);
} }
Control::Exit => { Control::Exit => {
self.process_event( self.process_event(
@ -601,6 +609,26 @@ where
} }
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
Control::InitAdapter(id, window) => { Control::InitAdapter(id, window) => {
self.init_adapter(event_loop, id, window);
}
Control::Cleanup(id) => {
_ = self.adapters.remove(&id);
},
},
_ => {
break;
}
},
task::Poll::Ready(_) => {
event_loop.exit();
break;
}
};
}
}
#[cfg(feature = "a11y")]
fn init_adapter(&mut self, event_loop: &(dyn winit::event_loop::ActiveEventLoop + 'static), id: core::window::Id, window: Arc<dyn winit::window::Window + 'static>) {
use crate::a11y::*; use crate::a11y::*;
use iced_accessibility::accesskit::{ use iced_accessibility::accesskit::{
ActivationHandler, Node, NodeId, Role, ActivationHandler, Node, NodeId, Role,
@ -641,25 +669,7 @@ where
), ),
); );
self.process_event(
event_loop,
Some(Event::A11yAdapter(id)),
);
}
Control::Cleanup(id) => {
_ = self.adapters.remove(&id);
},
},
_ => {
break;
}
},
task::Poll::Ready(_) => {
event_loop.exit();
break;
}
};
}
} }
} }
@ -842,10 +852,7 @@ async fn run_instance<P>(
on_open, on_open,
resize_border resize_border
} => { } => {
#[cfg(feature = "a11y")]
control_sender
.start_send(Control::InitAdapter(id, window.clone()))
.expect("Send control message");
#[cfg(all(feature = "cctk", target_os = "linux"))] #[cfg(all(feature = "cctk", target_os = "linux"))]
platform_specific_handler.send_wayland( platform_specific_handler.send_wayland(
platform_specific::Action::TrackWindow(window.clone(), id), platform_specific::Action::TrackWindow(window.clone(), id),