summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-02-04 15:15:15 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-02-04 15:15:15 +0200
commitcf37fc31c6ef9a4ed01b6b9b642b858d2b7965eb (patch)
treeeaa5f3d36e4470441d7fae540c233ff364d187a6
parent69541c037e67635787b334b326a4850f1703a763 (diff)
App: Event processing tweak
Refresh events will never be dispatched (it would be pointless), but instead just set a flag that prevents SDL_WaitEvent() to be called. SDL_WaitEvent() should never be called anyway because `pendingRefresh` is set, but this makes it clearer and skips other unnecessary checks.
-rw-r--r--src/app.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/app.c b/src/app.c
index 9f35d727..3e6e9cdc 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1291,9 +1291,10 @@ void processEvents_App(enum iAppEventMode eventMode) {
1291 iRoot *oldCurrentRoot = current_Root(); /* restored afterwards */ 1291 iRoot *oldCurrentRoot = current_Root(); /* restored afterwards */
1292 SDL_Event ev; 1292 SDL_Event ev;
1293 iBool gotEvents = iFalse; 1293 iBool gotEvents = iFalse;
1294 iBool gotRefresh = iFalse;
1294 iPtrArray windows; 1295 iPtrArray windows;
1295 init_PtrArray(&windows); 1296 init_PtrArray(&windows);
1296 while (nextEvent_App_(d, eventMode, &ev)) { 1297 while (nextEvent_App_(d, gotRefresh ? postedEventsOnly_AppEventMode : eventMode, &ev)) {
1297#if defined (iPlatformAppleMobile) 1298#if defined (iPlatformAppleMobile)
1298 if (processEvent_iOS(&ev)) { 1299 if (processEvent_iOS(&ev)) {
1299 continue; 1300 continue;
@@ -1364,6 +1365,10 @@ void processEvents_App(enum iAppEventMode eventMode) {
1364 dispatchCommands_Periodic(&d->periodic); 1365 dispatchCommands_Periodic(&d->periodic);
1365 continue; 1366 continue;
1366 } 1367 }
1368 if (ev.type == SDL_USEREVENT && ev.user.code == refresh_UserEventCode) {
1369 gotRefresh = iTrue;
1370 continue;
1371 }
1367#if defined (LAGRANGE_ENABLE_IDLE_SLEEP) 1372#if defined (LAGRANGE_ENABLE_IDLE_SLEEP)
1368 if (ev.type == SDL_USEREVENT && ev.user.code == asleep_UserEventCode) { 1373 if (ev.type == SDL_USEREVENT && ev.user.code == asleep_UserEventCode) {
1369 if (SDL_GetTicks() - d->lastEventTime > idleThreshold_App_ && 1374 if (SDL_GetTicks() - d->lastEventTime > idleThreshold_App_ &&