From 7f24c276457a3ab3f32ea670c785127e674828e2 Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Fri, 11 Oct 2024 08:36:09 -0700 Subject: [PATCH] Fix `minimising` example minimizing every frame (#15850) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective The `minimising` example is a bit annoying to run locally, because it attempts to minimize the window every frame, so un-minimizing it is difficult. ## Solution Only minimize once. The contents of the example can now be inspected, and the window easily closed after the minimization happens. ## Testing `cargo run --example minimising` I tested on macos only. --------- Co-authored-by: François Mockers --- tests/window/minimising.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/window/minimising.rs b/tests/window/minimising.rs index e4a9184111..9c9959b09d 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,13 @@ 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) { + 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