Merge branch 'master' into beacon
This commit is contained in:
commit
3f67044977
62 changed files with 713 additions and 780 deletions
|
|
@ -503,33 +503,10 @@ async fn run_instance<P>(
|
|||
let mut ui_caches = FxHashMap::default();
|
||||
let mut user_interfaces = ManuallyDrop::new(FxHashMap::default());
|
||||
let mut clipboard = Clipboard::unconnected();
|
||||
let mut compositor_receiver: Option<oneshot::Receiver<_>> = None;
|
||||
|
||||
loop {
|
||||
let event = if compositor_receiver.is_some() {
|
||||
let compositor_receiver =
|
||||
compositor_receiver.take().expect("Waiting for compositor");
|
||||
|
||||
match compositor_receiver.await {
|
||||
Ok(Ok((new_compositor, event))) => {
|
||||
compositor = Some(new_compositor);
|
||||
|
||||
Some(event)
|
||||
}
|
||||
Ok(Err(error)) => {
|
||||
control_sender
|
||||
.start_send(Control::Crash(
|
||||
Error::GraphicsCreationFailed(error),
|
||||
))
|
||||
.expect("Send control action");
|
||||
break;
|
||||
}
|
||||
Err(error) => {
|
||||
panic!("Compositor initialization failed: {error}")
|
||||
}
|
||||
}
|
||||
// Empty the queue if possible
|
||||
} else if let Ok(event) = event_receiver.try_next() {
|
||||
let event = if let Ok(event) = event_receiver.try_next() {
|
||||
event
|
||||
} else {
|
||||
event_receiver.next().await
|
||||
|
|
@ -548,17 +525,17 @@ async fn run_instance<P>(
|
|||
on_open,
|
||||
} => {
|
||||
if compositor.is_none() {
|
||||
let (compositor_sender, new_compositor_receiver) =
|
||||
let (compositor_sender, compositor_receiver) =
|
||||
oneshot::channel();
|
||||
|
||||
compositor_receiver = Some(new_compositor_receiver);
|
||||
|
||||
let create_compositor = {
|
||||
let window = window.clone();
|
||||
let mut proxy = proxy.clone();
|
||||
let default_fonts = default_fonts.clone();
|
||||
|
||||
async move {
|
||||
let mut compositor =
|
||||
<P::Renderer as compositor::Default>::Compositor::new(graphics_settings, window.clone()).await;
|
||||
<P::Renderer as compositor::Default>::Compositor::new(graphics_settings, window).await;
|
||||
|
||||
if let Ok(compositor) = &mut compositor {
|
||||
for font in default_fonts {
|
||||
|
|
@ -567,34 +544,42 @@ async fn run_instance<P>(
|
|||
}
|
||||
|
||||
compositor_sender
|
||||
.send(compositor.map(|compositor| {
|
||||
(
|
||||
compositor,
|
||||
Event::WindowCreated {
|
||||
id,
|
||||
window,
|
||||
exit_on_close_request,
|
||||
make_visible,
|
||||
on_open,
|
||||
},
|
||||
)
|
||||
}))
|
||||
.send(compositor)
|
||||
.ok()
|
||||
.expect("Send compositor");
|
||||
|
||||
// HACK! Send a proxy event on completion to trigger
|
||||
// a runtime re-poll
|
||||
// TODO: Send compositor through proxy (?)
|
||||
{
|
||||
let (sender, _receiver) = oneshot::channel();
|
||||
|
||||
proxy.send_action(Action::Window(
|
||||
runtime::window::Action::GetLatest(sender),
|
||||
));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
crate::futures::futures::executor::block_on(
|
||||
create_compositor,
|
||||
);
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
wasm_bindgen_futures::spawn_local(create_compositor);
|
||||
}
|
||||
wasm_bindgen_futures::spawn_local(create_compositor);
|
||||
|
||||
continue;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
runtime.block_on(create_compositor);
|
||||
|
||||
match compositor_receiver
|
||||
.await
|
||||
.expect("Wait for compositor")
|
||||
{
|
||||
Ok(new_compositor) => {
|
||||
compositor = Some(new_compositor);
|
||||
}
|
||||
Err(error) => {
|
||||
let _ = control_sender
|
||||
.start_send(Control::Crash(error.into()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug::theme_changed(|| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue