From cf37fc31c6ef9a4ed01b6b9b642b858d2b7965eb Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 4 Feb 2022 15:15:15 +0200 Subject: 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. --- src/app.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') 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) { iRoot *oldCurrentRoot = current_Root(); /* restored afterwards */ SDL_Event ev; iBool gotEvents = iFalse; + iBool gotRefresh = iFalse; iPtrArray windows; init_PtrArray(&windows); - while (nextEvent_App_(d, eventMode, &ev)) { + while (nextEvent_App_(d, gotRefresh ? postedEventsOnly_AppEventMode : eventMode, &ev)) { #if defined (iPlatformAppleMobile) if (processEvent_iOS(&ev)) { continue; @@ -1364,6 +1365,10 @@ void processEvents_App(enum iAppEventMode eventMode) { dispatchCommands_Periodic(&d->periodic); continue; } + if (ev.type == SDL_USEREVENT && ev.user.code == refresh_UserEventCode) { + gotRefresh = iTrue; + continue; + } #if defined (LAGRANGE_ENABLE_IDLE_SLEEP) if (ev.type == SDL_USEREVENT && ev.user.code == asleep_UserEventCode) { if (SDL_GetTicks() - d->lastEventTime > idleThreshold_App_ && -- cgit v1.2.3