Skip to content

Commit

Permalink
Fix minimising example minimizing every frame (#15850)
Browse files Browse the repository at this point in the history
# 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>
  • Loading branch information
rparrett and mockersf authored Oct 11, 2024
1 parent 9cfb4a1 commit 7f24c27
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/window/minimising.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7f24c27

Please sign in to comment.