summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-25 15:37:29 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-25 15:37:29 +0200
commitaf356ea33f54e81b35ca24274cc33e6fc295e019 (patch)
tree27440035b2308527def91169a8c4ee9f8654b37b
parentca442991158d525f3a8e2f5c31492921059f4797 (diff)
App: Tweaking idle sleep for mobile
-rw-r--r--src/app.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/app.c b/src/app.c
index 3ee2345c..3b4c24f0 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1208,10 +1208,6 @@ iLocalDef iBool isWaitingAllowed_App_(iApp *d) {
1208} 1208}
1209 1209
1210static iBool nextEvent_App_(iApp *d, enum iAppEventMode eventMode, SDL_Event *event) { 1210static iBool nextEvent_App_(iApp *d, enum iAppEventMode eventMode, SDL_Event *event) {
1211 if (d->isSuspended) {
1212 /* Do nothing except wait for the app to return to the foreground. */
1213 return SDL_WaitEvent(event);
1214 }
1215 if (eventMode == waitForNewEvents_AppEventMode && isWaitingAllowed_App_(d)) { 1211 if (eventMode == waitForNewEvents_AppEventMode && isWaitingAllowed_App_(d)) {
1216 /* If there are periodic commands pending, wait only for a short while. */ 1212 /* If there are periodic commands pending, wait only for a short while. */
1217 if (!isEmpty_Periodic(&d->periodic)) { 1213 if (!isEmpty_Periodic(&d->periodic)) {
@@ -1462,10 +1458,10 @@ void processEvents_App(enum iAppEventMode eventMode) {
1462 deinit_PtrArray(&windows); 1458 deinit_PtrArray(&windows);
1463#if defined (LAGRANGE_ENABLE_IDLE_SLEEP) 1459#if defined (LAGRANGE_ENABLE_IDLE_SLEEP)
1464 if (d->isIdling && !gotEvents) { 1460 if (d->isIdling && !gotEvents) {
1465 /* This is where we spend most of our time when idle. 60 Hz still quite a lot but we 1461 /* This is where we spend most of our time when idle. 30 Hz still quite a lot but we
1466 can't wait too long after the user tries to interact again with the app. In any 1462 can't wait too long after the user tries to interact again with the app. In any
1467 case, on macOS SDL_WaitEvent() seems to use 10x more CPU time than sleeping. */ 1463 case, on iOS SDL_WaitEvent() seems to use 10x more CPU time than sleeping (2.0.18). */
1468 SDL_Delay(1000 / 60); 1464 SDL_Delay(1000 / 30);
1469 } 1465 }
1470#endif 1466#endif
1471backToMainLoop:; 1467backToMainLoop:;