From 6e82633b5610cd04fd85996bf995d4b59da84e43 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Sat, 19 Oct 2024 12:33:42 -0300 Subject: [PATCH] love.visible is called when minimizing/unminimizing the window. --- src/modules/event/sdl/Event.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/modules/event/sdl/Event.cpp b/src/modules/event/sdl/Event.cpp index ceedaa9f8..9afcf0bda 100644 --- a/src/modules/event/sdl/Event.cpp +++ b/src/modules/event/sdl/Event.cpp @@ -664,7 +664,20 @@ Message *Event::convertWindowEvent(const SDL_Event &e) break; case SDL_EVENT_WINDOW_SHOWN: case SDL_EVENT_WINDOW_HIDDEN: - vargs.emplace_back(event == SDL_EVENT_WINDOW_SHOWN); + case SDL_EVENT_WINDOW_MINIMIZED: + case SDL_EVENT_WINDOW_RESTORED: +#ifdef LOVE_ANDROID + if (auto audio = Module::getInstance(Module::M_AUDIO)) + { + if (event == SDL_EVENT_WINDOW_MINIMIZED) + audio->pauseContext(); + else if (event == SDL_EVENT_WINDOW_RESTORED) + audio->resumeContext(); + } +#endif + // WINDOW_RESTORED can also happen when going from maximized -> unmaximized, + // but there isn't a nice way to avoid sending our event in that situation. + vargs.emplace_back(event == SDL_EVENT_WINDOW_SHOWN || event == SDL_EVENT_WINDOW_RESTORED); msg = new Message("visible", vargs); break; case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED: @@ -696,18 +709,6 @@ Message *Event::convertWindowEvent(const SDL_Event &e) msg = new Message("resize", vargs); } break; - case SDL_EVENT_WINDOW_MINIMIZED: - case SDL_EVENT_WINDOW_RESTORED: -#ifdef LOVE_ANDROID - if (auto audio = Module::getInstance(Module::M_AUDIO)) - { - if (event == SDL_EVENT_WINDOW_MINIMIZED) - audio->pauseContext(); - else if (event == SDL_EVENT_WINDOW_RESTORED) - audio->resumeContext(); - } -#endif - break; } return msg;