From 5cbfa8c7fabdeb30854e7a64aefbf65263c4239e Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Fri, 11 Oct 2024 06:21:15 -0700 Subject: [PATCH 1/4] Fix `minimising` example minimizing every frame --- tests/window/minimising.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/window/minimising.rs b/tests/window/minimising.rs index e4a9184111cdd..06fb42d35a0c1 100644 --- a/tests/window/minimising.rs +++ b/tests/window/minimising.rs @@ -1,6 +1,6 @@ //! A test to confirm that `bevy` allows minimising the window //! This is run in CI to ensure that this doesn't regress again. -use bevy::prelude::*; +use bevy::{core::FrameCount, prelude::*}; fn main() { // TODO: Combine this with `resizing` once multiple_windows is simpler than @@ -18,13 +18,19 @@ fn main() { .run(); } -fn minimise_automatically(mut windows: Query<&mut Window>, mut frames: Local) { - if *frames == 60 { - let mut window = windows.single_mut(); - window.set_minimized(true); - } else { - *frames += 1; +fn minimise_automatically( + mut windows: Query<&mut Window>, + frames: Res, + mut done: Local, +) { + if *done || frames.0 < 60 { + return; } + + let mut window = windows.single_mut(); + window.set_minimized(true); + + *done = true } /// A simple 3d scene, taken from the `3d_scene` example From d2acd21fc3d64849568f31ed1e0a5db71e0e11ab Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Fri, 11 Oct 2024 06:32:31 -0700 Subject: [PATCH 2/4] Fix error --- tests/window/minimising.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/window/minimising.rs b/tests/window/minimising.rs index 06fb42d35a0c1..9e56f8bfaa095 100644 --- a/tests/window/minimising.rs +++ b/tests/window/minimising.rs @@ -30,7 +30,7 @@ fn minimise_automatically( let mut window = windows.single_mut(); window.set_minimized(true); - *done = true + *done = true; } /// A simple 3d scene, taken from the `3d_scene` example From 3966aed2c0c269b60910314dc2ff73485e6c6461 Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Fri, 11 Oct 2024 06:58:33 -0700 Subject: [PATCH 3/4] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Mockers --- tests/window/minimising.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/window/minimising.rs b/tests/window/minimising.rs index 9e56f8bfaa095..ba541a667ec4a 100644 --- a/tests/window/minimising.rs +++ b/tests/window/minimising.rs @@ -21,16 +21,14 @@ fn main() { fn minimise_automatically( mut windows: Query<&mut Window>, frames: Res, - mut done: Local, ) { - if *done || frames.0 < 60 { + if frames.0 != 60 { return; } let mut window = windows.single_mut(); window.set_minimized(true); - *done = true; } /// A simple 3d scene, taken from the `3d_scene` example From 2ef862710064300a4e3bba78c40865ce871f2c1e Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Fri, 11 Oct 2024 07:07:12 -0700 Subject: [PATCH 4/4] fmt after suggestions --- tests/window/minimising.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/window/minimising.rs b/tests/window/minimising.rs index ba541a667ec4a..9c9959b09daf2 100644 --- a/tests/window/minimising.rs +++ b/tests/window/minimising.rs @@ -18,17 +18,13 @@ fn main() { .run(); } -fn minimise_automatically( - mut windows: Query<&mut Window>, - frames: Res, -) { +fn minimise_automatically(mut windows: Query<&mut Window>, frames: Res) { if frames.0 != 60 { return; } let mut window = windows.single_mut(); window.set_minimized(true); - } /// A simple 3d scene, taken from the `3d_scene` example