Skip to content

Commit 7f24c27

Browse files
rparrettmockersf
andauthored
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 <[email protected]>
1 parent 9cfb4a1 commit 7f24c27

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/window/minimising.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! A test to confirm that `bevy` allows minimising the window
22
//! This is run in CI to ensure that this doesn't regress again.
3-
use bevy::prelude::*;
3+
use bevy::{core::FrameCount, prelude::*};
44

55
fn main() {
66
// TODO: Combine this with `resizing` once multiple_windows is simpler than
@@ -18,13 +18,13 @@ fn main() {
1818
.run();
1919
}
2020

21-
fn minimise_automatically(mut windows: Query<&mut Window>, mut frames: Local<u32>) {
22-
if *frames == 60 {
23-
let mut window = windows.single_mut();
24-
window.set_minimized(true);
25-
} else {
26-
*frames += 1;
21+
fn minimise_automatically(mut windows: Query<&mut Window>, frames: Res<FrameCount>) {
22+
if frames.0 != 60 {
23+
return;
2724
}
25+
26+
let mut window = windows.single_mut();
27+
window.set_minimized(true);
2828
}
2929

3030
/// A simple 3d scene, taken from the `3d_scene` example

0 commit comments

Comments
 (0)