From 54b3653492440bd54b63edbbe9f18fcac4e676d2 Mon Sep 17 00:00:00 2001 From: Andrew William Watson Date: Tue, 12 Mar 2024 09:25:16 -0400 Subject: [PATCH 1/2] WinitConfig -> WinitSettings in docs, mouse_button_input -> button_input, spacebar -> space bar --- examples/window/low_power.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/window/low_power.rs b/examples/window/low_power.rs index f175167130399..b0a0436946fa4 100644 --- a/examples/window/low_power.rs +++ b/examples/window/low_power.rs @@ -16,7 +16,7 @@ fn main() { .insert_resource(WinitSettings::game()) // Power-saving reactive rendering for applications. .insert_resource(WinitSettings::desktop_app()) - // You can also customize update behavior with the fields of [`WinitConfig`] + // You can also customize update behavior with the fields of [`WinitSettings`] .insert_resource(WinitSettings { focused_mode: bevy::winit::UpdateMode::Continuous, unfocused_mode: bevy::winit::UpdateMode::ReactiveLowPower { @@ -61,13 +61,13 @@ fn update_winit( use ExampleMode::*; *winit_config = match *mode { Game => { - // In the default `WinitConfig::game()` mode: + // In the default `WinitSettings::game()` mode: // * When focused: the event loop runs as fast as possible // * When not focused: the event loop runs as fast as possible WinitSettings::game() } Application => { - // While in `WinitConfig::desktop_app()` mode: + // While in `WinitSettings::desktop_app()` mode: // * When focused: the app will update any time a winit event (e.g. the window is // moved/resized, the mouse moves, a button is pressed, etc.), a [`RequestRedraw`] // event is received, or after 5 seconds if the app has not updated. @@ -80,7 +80,7 @@ fn update_winit( ApplicationWithRedraw => { // Sending a `RequestRedraw` event is useful when you want the app to update the next // frame regardless of any user input. For example, your application might use - // `WinitConfig::desktop_app()` to reduce power use, but UI animations need to play even + // `WinitSettings::desktop_app()` to reduce power use, but UI animations need to play even // when there are no inputs, so you send redraw requests while the animation is playing. event.send(RequestRedraw); WinitSettings::desktop_app() @@ -101,9 +101,9 @@ pub(crate) mod test_setup { /// Switch between update modes when the mouse is clicked. pub(crate) fn cycle_modes( mut mode: ResMut, - mouse_button_input: Res>, + button_input: Res>, ) { - if mouse_button_input.just_pressed(KeyCode::Space) { + if button_input.just_pressed(KeyCode::Space) { *mode = match *mode { ExampleMode::Game => ExampleMode::Application, ExampleMode::Application => ExampleMode::ApplicationWithRedraw, @@ -173,7 +173,7 @@ pub(crate) mod test_setup { commands.spawn(( TextBundle::from_sections([ TextSection::new( - "Press spacebar to cycle modes\n", + "Press space bar to cycle modes\n", TextStyle { font_size: 50.0, ..default() From 50887acc49f65b5e8662d79a1aa7bb0500558424 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 12 Mar 2024 17:48:14 -0400 Subject: [PATCH 2/2] Update examples/window/low_power.rs fixed out-of-date comment on unfocused_mode behaviour for Game mode --- examples/window/low_power.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/window/low_power.rs b/examples/window/low_power.rs index b0a0436946fa4..3782d50171c0d 100644 --- a/examples/window/low_power.rs +++ b/examples/window/low_power.rs @@ -63,7 +63,10 @@ fn update_winit( Game => { // In the default `WinitSettings::game()` mode: // * When focused: the event loop runs as fast as possible - // * When not focused: the event loop runs as fast as possible + // * When not focused: the app will update when the window is directly interacted with + // (e.g. the mouse hovers over a visible part of the out of focus window), a + // [`RequestRedraw`] event is received, or one sixtieth of a second has passed + // without the app updating (60 Hz refresh rate max). WinitSettings::game() } Application => {