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.
This commit is contained in:
Matt Campbell 2025-03-16 19:41:19 -05:00 committed by GitHub
parent 79655269f5
commit 35526743b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);