Improve macOS/iOS/Web thread safety

Co-authored-by: daxpedda <daxpedda@gmail.com>
This commit is contained in:
Mads Marquart
2023-08-14 21:19:57 +02:00
committed by Kirill Chibisov
parent 65c2482d74
commit 4e6ce00ec5
20 changed files with 552 additions and 724 deletions

View File

@@ -31,7 +31,7 @@ use crate::event::Event;
use crate::event_loop::ControlFlow;
use crate::event_loop::EventLoop;
use crate::event_loop::EventLoopWindowTarget;
use crate::window::WindowBuilder;
use crate::window::{Window, WindowBuilder};
use web_sys::HtmlCanvasElement;
@@ -40,6 +40,13 @@ pub trait WindowExtWebSys {
fn canvas(&self) -> Option<HtmlCanvasElement>;
}
impl WindowExtWebSys for Window {
#[inline]
fn canvas(&self) -> Option<HtmlCanvasElement> {
self.window.canvas()
}
}
pub trait WindowBuilderExtWebSys {
/// Pass an [`HtmlCanvasElement`] to be used for this [`Window`](crate::window::Window). If
/// [`None`], [`WindowBuilder::build()`] will create one.