From 35526743b3b73cf13550cdb10002c615709c3122 Mon Sep 17 00:00:00 2001 From: Matt Campbell Date: Sun, 16 Mar 2025 19:41:19 -0500 Subject: [PATCH] bevy_winit: Create the window initially invisible as required by AccessKit (#18346) The initial `with_visible` call was intended to do this, but that was undone by a later `with_visible` call. --- crates/bevy_winit/src/winit_windows.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index 49698f9f97..cd281103e4 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -110,14 +110,16 @@ impl WinitWindows { } }; + // It's crucial to avoid setting the window's final visibility here; + // as explained above, the window must be invisible until the AccessKit + // adapter is created. winit_window_attributes = winit_window_attributes .with_window_level(convert_window_level(window.window_level)) .with_theme(window.window_theme.map(convert_window_theme)) .with_resizable(window.resizable) .with_enabled_buttons(convert_enabled_buttons(window.enabled_buttons)) .with_decorations(window.decorations) - .with_transparent(window.transparent) - .with_visible(window.visible); + .with_transparent(window.transparent); #[cfg(target_os = "windows")] { @@ -284,6 +286,10 @@ impl WinitWindows { handlers, ); + // Now that the AccessKit adapter is created, it's safe to show + // the window. + winit_window.set_visible(window.visible); + // Do not set the grab mode on window creation if it's none. It can fail on mobile. if window.cursor_options.grab_mode != CursorGrabMode::None { let _ = attempt_grab(&winit_window, window.cursor_options.grab_mode);