From 58b4bbc5e92d4eb64da507d44fe5bbc9f535eee5 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 18 May 2021 12:33:10 +0300 Subject: App: Attempt to fix app restore issue Cached content like font glyphs are (were?) not being restored when returning to foreground. --- src/app.c | 3 +++ src/ui/window.c | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/app.c b/src/app.c index 6c559f33..d259f541 100644 --- a/src/app.c +++ b/src/app.c @@ -1008,6 +1008,9 @@ void processEvents_App(enum iAppEventMode eventMode) { case SDL_APP_LOWMEMORY: clearCache_App_(); break; + case SDL_APP_WILLENTERFOREGROUND: + invalidate_Window(d->window); + break; case SDL_APP_DIDENTERFOREGROUND: gotEvents = iTrue; d->warmupFrames = 5; diff --git a/src/ui/window.c b/src/ui/window.c index 5bf2aa53..252b3bdb 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -566,14 +566,18 @@ iRoot *otherRoot_Window(const iWindow *d, iRoot *root) { return root == d->roots[0] && d->roots[1] ? d->roots[1] : d->roots[0]; } -void invalidate_Window(iWindow *d) { - if (d && !d->isInvalidated) { +static void invalidate_Window_(iWindow *d, iBool forced) { + if (d && (!d->isInvalidated || forced)) { d->isInvalidated = iTrue; resetFonts_Text(); postCommand_App("theme.changed auto:1"); /* forces UI invalidation */ } } +void invalidate_Window(iWindow *d) { + invalidate_Window_(d, iFalse); +} + static iBool isNormalPlacement_Window_(const iWindow *d) { if (d->isDrawFrozen) return iFalse; #if defined (iPlatformApple) @@ -741,14 +745,14 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { return iTrue; case SDL_WINDOWEVENT_RESTORED: updateSize_Window_(d, iTrue); - invalidate_Window(d); + invalidate_Window_(d, iTrue); d->isMinimized = iFalse; postRefresh_App(); return iTrue; case SDL_WINDOWEVENT_MINIMIZED: d->isMinimized = iTrue; return iTrue; -#endif +#endif /* defined (iPlatformDesktop) */ case SDL_WINDOWEVENT_LEAVE: unhover_Widget(); d->isMouseInside = iFalse; @@ -772,7 +776,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { d->isExposed = iTrue; #if defined (iPlatformMobile) /* Returned to foreground, may have lost buffered content. */ - invalidate_Window(d); + invalidate_Window_(d, iTrue); postCommand_App("window.unfreeze"); #endif return iFalse; -- cgit v1.2.3