bevyengine/bevy
bevy_window
Platform-agnostic windowing types. Defines Window, window events, modes (windowed/fullscreen/borderless), cursor settings, and the API the OS-specific backend (bevy_winit) implements against.
Purpose
The crate is data + events. The actual OS window is owned by bevy_winit; bevy_window just exposes the types so other crates (input, picking, rendering) can be backend-agnostic.
Directory layout
crates/bevy_window/src/
├── lib.rs # WindowPlugin, prelude
├── window.rs # Window component + WindowResolution
├── event.rs # WindowResized, CursorEntered, FileDragAndDrop, ...
├── cursor.rs # CursorIcon, CursorOptions
├── monitor.rs # Monitor info
├── system.rs # Per-frame helper systems
└── system_cursor.rsKey abstractions
| Type | File | Description |
|---|---|---|
Window |
crates/bevy_window/src/window.rs |
Component on a window entity. |
WindowPlugin |
crates/bevy_window/src/lib.rs |
Adds the resources/events. |
PrimaryWindow |
crates/bevy_window/src/lib.rs |
Marker on the main window entity. |
WindowResized, WindowCloseRequested, WindowFocused, … |
crates/bevy_window/src/event.rs |
Lifecycle events. |
Monitor, Monitors |
crates/bevy_window/src/monitor.rs |
Monitor info from the OS. |
CursorIcon, CursorOptions |
crates/bevy_window/src/cursor.rs |
Cursor config. |
How it works
Each OS window is an ECS entity with a Window component. bevy_winit owns the OS handle and watches for ECS changes (resize, fullscreen toggle, cursor changes) to push to the OS, and for OS events to translate back into the corresponding event resource.
PrimaryWindow is a marker component the default plugins put on the first window. Many systems use Query<&Window, With<PrimaryWindow>> to grab "the" window.
Integration points
- Depends on:
bevy_app,bevy_ecs,bevy_math,bevy_a11y,bevy_image(for cursor images),bevy_reflect. - Depended on by:
bevy_winit,bevy_render,bevy_camera,bevy_input,bevy_picking,bevy_ui.
Entry points for modification
- New window property: add a field to
Windowand propagate viabevy_winit. - New event: add to
event.rsand emit frombevy_winit. - Cursor:
cursor.rsfor the data,bevy_winitfor the OS bridge.
See also
bevy_winit— the OS-specific backend.bevy_render— renders into aWindow's swapchain.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.