Skip to content

Commit 7acf9a0

Browse files
committed
rate limit
1 parent 31f40d5 commit 7acf9a0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

crates/bevy_winit/src/winit_config.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,24 @@ pub struct WinitSettings {
3333
pub unfocused_mode: UpdateMode,
3434
}
3535
impl WinitSettings {
36-
/// Configure winit with common settings for a game.
36+
/// Default settings for games.
37+
///
38+
/// [`Continuous`](UpdateMode::Continuous) if windows have focus,
39+
/// [`ReactiveLowPower`](UpdateMode::ReactiveLowPower) otherwise.
3740
pub fn game() -> Self {
38-
WinitSettings::default()
41+
WinitSettings {
42+
focused_mode: UpdateMode::Continuous,
43+
unfocused_mode: UpdateMode::ReactiveLowPower {
44+
max_wait: Duration::from_millis(50), // 20Hz
45+
},
46+
..Default::default()
47+
}
3948
}
4049

41-
/// Configure winit with common settings for a desktop application.
50+
/// Default settings for desktop applications.
51+
///
52+
/// [`Reactive`](UpdateMode::Reactive) if windows have focus,
53+
/// [`ReactiveLowPower`](UpdateMode::ReactiveLowPower) otherwise.
4254
pub fn desktop_app() -> Self {
4355
WinitSettings {
4456
focused_mode: UpdateMode::Reactive {

0 commit comments

Comments
 (0)