background processing
Some checks failed
ContinuousIntegration / linux (pull_request) Successful in 4m6s
ContinuousDelivery / linux-ubuntu (pull_request) Failing after 5m5s
ContinuousIntegration / android (pull_request) Failing after 5m44s
ContinuousDelivery / windows (pull_request) Has been cancelled
ContinuousDelivery / windows-asan (pull_request) Has been cancelled
ContinuousIntegration / macos (pull_request) Has been cancelled
ContinuousIntegration / windows (pull_request) Has been cancelled
ContinuousDelivery / release (pull_request) Has been cancelled

This commit is contained in:
Green Sky 2024-06-04 17:53:49 +02:00
parent b0e25627b3
commit 56f1bf559c
No known key found for this signature in database
2 changed files with 11 additions and 4 deletions

View File

@ -76,9 +76,8 @@
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:hardwareAccelerated="true" > android:hardwareAccelerated="true" >
<!-- Example of setting SDL hints from AndroidManifest.xml: <!-- setting sdl hints. uses the string value -->
<meta-data android:name="SDL_ENV.SDL_ANDROID_TRAP_BACK_BUTTON" android:value="0"/> <meta-data android:name="SDL_ENV.SDL_ANDROID_BLOCK_ON_PAUSE" android:value="0"/>
-->
<activity android:name="TomatoActivity" <activity android:name="TomatoActivity"
android:label="@string/app_name" android:label="@string/app_name"

View File

@ -106,7 +106,7 @@ int main(int argc, char** argv) {
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>(args, renderer.get(), theme); std::unique_ptr<Screen> screen = std::make_unique<StartScreen>(args, renderer.get(), theme);
bool is_background = false;
bool quit = false; bool quit = false;
while (!quit) { while (!quit) {
auto new_time = std::chrono::steady_clock::now(); auto new_time = std::chrono::steady_clock::now();
@ -131,6 +131,10 @@ int main(int argc, char** argv) {
if (event.type == SDL_EVENT_QUIT) { if (event.type == SDL_EVENT_QUIT) {
quit = true; quit = true;
break; break;
} else if (event.type == SDL_EVENT_WILL_ENTER_BACKGROUND) {
is_background = true;
} else if (event.type == SDL_EVENT_DID_ENTER_FOREGROUND) {
is_background = false;
} }
if (screen->handleEvent(event)) { if (screen->handleEvent(event)) {
@ -143,6 +147,10 @@ int main(int argc, char** argv) {
break; break;
} }
if (is_background) {
render = false;
}
// can do both in the same loop // can do both in the same loop
if (render) { if (render) {
ImGui_ImplSDLRenderer3_NewFrame(); ImGui_ImplSDLRenderer3_NewFrame();