--- name: bevy-windows description: Reference for Bevy windows — Window component, physical vs logical size, resolution, cursors, multi-window, events, screenshots, and reactive rendering. metadata: crate: bevy_window bevy: "0.19" --- ## Window component The `Window` component holds all window settings (position, size, title, etc.). The `PrimaryWindow` marker is added to the default window. ```rust fn log(window: Single<&Window>) { info!("width: {}, height: {}", window.width(), window.height()); } ``` ## Physical vs logical size - **Physical size** — actual pixels on monitor (unscaled) - **Logical size** — physical / `scale_factor` - **Requested size** — logical size submitted to API ## Configuring the primary window ```rust app.add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "My Game".into(), resolution: WindowResolution::new(500, 300).with_scale_factor_override(1.0), present_mode: PresentMode::AutoVsync, ..default() }), ..default() })); ``` ## Querying windows ```rust fn inspect(windows: Query<&Window, With>) { for window in &windows { let logical = (window.width(), window.height()); let physical = (window.physical_width(), window.physical_height()); let cursor = window.cursor_position(); // Option } } ``` ## Changing resolution at runtime ```rust fn resize(mut window: Single<&mut Window>, keys: Res>) { if keys.just_pressed(KeyCode::Digit1) { window.resolution.set(800., 600.); } } ``` ## Changing title ```rust fn title(mut windows: Query<&mut Window>, time: Res