bevy/crates
Benjamin Brienen 818a8fe154
Allow unfocused window creation (#19237)
# Objective

Allow creating a new window without it being focused, when `Window`'s
`focused` is `false.
## Solution

Use `winit`'s `WindowBuilder`'s `with_active` method

## Notes

- `winit`'s doc lists [redox's
`Orbital`](https://gitlab.redox-os.org/redox-os/orbital) as an
unsupported platform, but since Bevy doesn't officially support this
platform, I didn't put it in the documentation.

- I only tested on Linux, which is an unsupported platform. I can give
you a test code if you want to test on another platform.

- I initially put a line
[here](https://github.com/bevyengine/bevy/blob/v0.11.0/crates/bevy_winit/src/system.rs#L72)
to set the Bevy `Window`'s `focused` to `winit_window.has_focus()` after
window creation to avoid the case where `with_active` is not supported,
the window is spawned focused, no `WindowFocused` event is triggered,
and Bevy `Window` would be desynced from winit's window. But after
testing on Linux (which doesn't support `with_active`) it seems like at
that point `has_focus` returns `false` and the event is triggered, so I
removed it. Do you think I should add it back to be safe?

## Changelog

- A new unfocused `Window` can be created by setting `focused` to
`false`.

## Migration Guide

- If a `Window` is spawned with `focused` set to `false`, it will now
start not focused on supported platforms.

Adopted from #9208

---------

Co-authored-by: Sélène Amanita <selene.amanita@net-c.com>
Co-authored-by: Sélène Amanita <134181069+Selene-Amanita@users.noreply.github.com>
Co-authored-by: atlv <email@atlasdostal.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-05-26 20:05:33 +00:00
..
bevy_a11y Bump accesskit to 0.19 and accesskit_winit to 0.27 (#19160) 2025-05-26 17:48:36 +00:00
bevy_animation Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
bevy_anti_aliasing Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
bevy_app Simplify bevy_utils Features (#19090) 2025-05-24 01:46:11 +00:00
bevy_asset Remove apostrophes in possessive its (#19244) 2025-05-26 19:53:14 +00:00
bevy_audio Remove apostrophes in possessive its (#19244) 2025-05-26 19:53:14 +00:00
bevy_color Implemented Alpha for f32. (#18653) 2025-05-06 00:00:17 +00:00
bevy_core_pipeline Split Camera.hdr out into a new component (#18873) 2025-05-26 19:24:45 +00:00
bevy_derive Remove upcasting methods + Cleanup interned label code (#18984) 2025-05-26 15:38:12 +00:00
bevy_dev_tools Improve visibility of debug picking node (#18990) 2025-05-26 15:39:49 +00:00
bevy_diagnostic Add missing doc comments to system_information_diagnostics_plugin (#19267) 2025-05-26 19:59:49 +00:00
bevy_dylib don't disable std in bevy_dylib (#18807) 2025-04-11 18:44:53 +00:00
bevy_ecs Fix a few typos in bevy_ecs docs (#19280) 2025-05-26 20:02:13 +00:00
bevy_encase_derive
bevy_gilrs Remove remaining internal use of !Send resources (#18386) 2025-05-06 22:23:59 +00:00
bevy_gizmos Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
bevy_gltf Make sure that serde_json::Map::into_values exists (#19229) 2025-05-26 19:38:28 +00:00
bevy_image Optional explicit compressed image format support (#19190) 2025-05-26 18:00:33 +00:00
bevy_input Simplify bevy_utils Features (#19090) 2025-05-24 01:46:11 +00:00
bevy_input_focus Navigate through TabGroups in order. (#19218) 2025-05-26 19:32:10 +00:00
bevy_internal Simplify bevy_utils Features (#19090) 2025-05-24 01:46:11 +00:00
bevy_log feat(log): support customizing default log formatting (#17722) 2025-05-05 23:01:06 +00:00
bevy_macro_utils Better macro errors for get_struct_fields (#17639) 2025-05-26 16:57:03 +00:00
bevy_math Add a Dir4 to resolve #17983 (#19223) 2025-05-26 19:35:07 +00:00
bevy_mesh Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
bevy_mikktspace fix new nightly lint on mikktspace (#18988) 2025-04-30 05:19:01 +00:00
bevy_pbr Split Camera.hdr out into a new component (#18873) 2025-05-26 19:24:45 +00:00
bevy_picking don't filter dragged entity out of DragEnter events (#19179) 2025-05-26 17:56:54 +00:00
bevy_platform Create bevy_platform::cfg for viral feature management (#18822) 2025-05-06 00:52:15 +00:00
bevy_ptr
bevy_reflect Make sure that serde_json::Map::into_values exists (#19229) 2025-05-26 19:38:28 +00:00
bevy_remote Make sure that serde_json::Map::into_values exists (#19229) 2025-05-26 19:38:28 +00:00
bevy_render Clarify RenderLayers docs (#19241) 2025-05-26 19:52:22 +00:00
bevy_scene Make entity generation a new type and remove identifier (#19121) 2025-05-08 04:03:05 +00:00
bevy_sprite Fix Anchor component inconsistancies (#18393) 2025-05-21 15:32:04 +00:00
bevy_state Remove apostrophes in possessive its (#19244) 2025-05-26 19:53:14 +00:00
bevy_tasks Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
bevy_text Remove apostrophes in possessive its (#19244) 2025-05-26 19:53:14 +00:00
bevy_time Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
bevy_transform Simplify bevy_utils Features (#19090) 2025-05-24 01:46:11 +00:00
bevy_ui Split Camera.hdr out into a new component (#18873) 2025-05-26 19:24:45 +00:00
bevy_utils Remove apostrophes in possessive its (#19244) 2025-05-26 19:53:14 +00:00
bevy_window Allow unfocused window creation (#19237) 2025-05-26 20:05:33 +00:00
bevy_winit Allow unfocused window creation (#19237) 2025-05-26 20:05:33 +00:00