From 7564db6b7c975764f6fe43ec256f5bdb794bd0ad Mon Sep 17 00:00:00 2001 From: daxpedda Date: Fri, 22 Dec 2023 09:58:42 +0100 Subject: [PATCH] Use `WindowBuilder::with_append()` to append canvas --- crates/bevy_winit/src/winit_windows.rs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index da4024aef8f0d..865eb7a02eedf 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -140,7 +140,8 @@ impl WinitWindows { } winit_window_builder = - winit_window_builder.with_prevent_default(window.prevent_default_event_handling) + winit_window_builder.with_prevent_default(window.prevent_default_event_handling); + winit_window_builder = winit_window_builder.with_append(true); } let winit_window = winit_window_builder.build(event_loop).unwrap(); @@ -189,22 +190,6 @@ impl WinitWindows { self.entity_to_winit.insert(entity, winit_window.id()); self.winit_to_entity.insert(winit_window.id(), entity); - #[cfg(target_arch = "wasm32")] - { - use winit::platform::web::WindowExtWebSys; - - if window.canvas.is_none() { - let canvas = winit_window.canvas().expect("Failed to retrieve canvas."); - - let window = web_sys::window().unwrap(); - let document = window.document().unwrap(); - let body = document.body().unwrap(); - - body.append_child(&canvas) - .expect("Append canvas to HTML body."); - } - } - self.windows .entry(winit_window.id()) .insert(winit_window)