summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-18 12:33:10 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-18 12:33:10 +0300
commitca13d25e1e3dc1b2b7ea865866e9e4a5785f26d1 (patch)
treead0c56b59e4a24d282e0670b5c66cd22702ec62e
parent8ac8290e282a8ce645abc6fd394e53f1de50ae99 (diff)
App: Attempt to fix app restore issue
Cached content like font glyphs are (were?) not being restored when returning to foreground.
-rw-r--r--src/app.c3
-rw-r--r--src/ui/window.c14
2 files changed, 12 insertions, 5 deletions
diff --git a/src/app.c b/src/app.c
index cc172139..26670a65 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1019,6 +1019,9 @@ void processEvents_App(enum iAppEventMode eventMode) {
1019 case SDL_APP_LOWMEMORY: 1019 case SDL_APP_LOWMEMORY:
1020 clearCache_App_(); 1020 clearCache_App_();
1021 break; 1021 break;
1022 case SDL_APP_WILLENTERFOREGROUND:
1023 invalidate_Window(d->window);
1024 break;
1022 case SDL_APP_DIDENTERFOREGROUND: 1025 case SDL_APP_DIDENTERFOREGROUND:
1023 gotEvents = iTrue; 1026 gotEvents = iTrue;
1024 d->warmupFrames = 5; 1027 d->warmupFrames = 5;
diff --git a/src/ui/window.c b/src/ui/window.c
index abdc363d..6b9956ea 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -566,14 +566,18 @@ iRoot *otherRoot_Window(const iWindow *d, iRoot *root) {
566 return root == d->roots[0] && d->roots[1] ? d->roots[1] : d->roots[0]; 566 return root == d->roots[0] && d->roots[1] ? d->roots[1] : d->roots[0];
567} 567}
568 568
569void invalidate_Window(iWindow *d) { 569static void invalidate_Window_(iWindow *d, iBool forced) {
570 if (d && !d->isInvalidated) { 570 if (d && (!d->isInvalidated || forced)) {
571 d->isInvalidated = iTrue; 571 d->isInvalidated = iTrue;
572 resetFonts_Text(); 572 resetFonts_Text();
573 postCommand_App("theme.changed auto:1"); /* forces UI invalidation */ 573 postCommand_App("theme.changed auto:1"); /* forces UI invalidation */
574 } 574 }
575} 575}
576 576
577void invalidate_Window(iWindow *d) {
578 invalidate_Window_(d, iFalse);
579}
580
577static iBool isNormalPlacement_Window_(const iWindow *d) { 581static iBool isNormalPlacement_Window_(const iWindow *d) {
578 if (d->isDrawFrozen) return iFalse; 582 if (d->isDrawFrozen) return iFalse;
579#if defined (iPlatformApple) 583#if defined (iPlatformApple)
@@ -741,14 +745,14 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
741 return iTrue; 745 return iTrue;
742 case SDL_WINDOWEVENT_RESTORED: 746 case SDL_WINDOWEVENT_RESTORED:
743 updateSize_Window_(d, iTrue); 747 updateSize_Window_(d, iTrue);
744 invalidate_Window(d); 748 invalidate_Window_(d, iTrue);
745 d->isMinimized = iFalse; 749 d->isMinimized = iFalse;
746 postRefresh_App(); 750 postRefresh_App();
747 return iTrue; 751 return iTrue;
748 case SDL_WINDOWEVENT_MINIMIZED: 752 case SDL_WINDOWEVENT_MINIMIZED:
749 d->isMinimized = iTrue; 753 d->isMinimized = iTrue;
750 return iTrue; 754 return iTrue;
751#endif 755#endif /* defined (iPlatformDesktop) */
752 case SDL_WINDOWEVENT_LEAVE: 756 case SDL_WINDOWEVENT_LEAVE:
753 unhover_Widget(); 757 unhover_Widget();
754 d->isMouseInside = iFalse; 758 d->isMouseInside = iFalse;
@@ -772,7 +776,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
772 d->isExposed = iTrue; 776 d->isExposed = iTrue;
773#if defined (iPlatformMobile) 777#if defined (iPlatformMobile)
774 /* Returned to foreground, may have lost buffered content. */ 778 /* Returned to foreground, may have lost buffered content. */
775 invalidate_Window(d); 779 invalidate_Window_(d, iTrue);
776 postCommand_App("window.unfreeze"); 780 postCommand_App("window.unfreeze");
777#endif 781#endif
778 return iFalse; 782 return iFalse;