From a598f317162e354e05e7c6af942cefcfac917a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sallai=20J=C3=B3zsef?= Date: Sun, 24 Jul 2022 19:38:39 +0300 Subject: [PATCH] don't pause the game loop when the window loses focus --- src/framework/backend_sdl2.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/framework/backend_sdl2.rs b/src/framework/backend_sdl2.rs index 09ac50d..6147324 100644 --- a/src/framework/backend_sdl2.rs +++ b/src/framework/backend_sdl2.rs @@ -237,21 +237,8 @@ impl BackendEventLoop for SDL2EventLoop { state.shutdown(); } Event::Window { win_event, .. } => match win_event { - WindowEvent::FocusGained | WindowEvent::Shown => { - { - let mut mutex = GAME_SUSPENDED.lock().unwrap(); - *mutex = false; - } - - state.sound_manager.resume(); - game.loops = 0; - } - WindowEvent::FocusLost | WindowEvent::Hidden => { - let mut mutex = GAME_SUSPENDED.lock().unwrap(); - *mutex = true; - - state.sound_manager.pause(); - } + WindowEvent::FocusGained | WindowEvent::Shown => {} + WindowEvent::FocusLost | WindowEvent::Hidden => {} WindowEvent::SizeChanged(width, height) => { ctx.screen_size = (width.max(1) as f32, height.max(1) as f32);