Fix minimising example minimizing every frame (#15850)

# 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 <francois.mockers@vleue.com>
This commit is contained in:
Rob Parrett 2024-10-11 08:36:09 -07:00 committed by GitHub
parent 9cfb4a187f
commit 7f24c27645
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<u32>) {
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<FrameCount>) {
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