Lagrange [work/v1.9]

App: Attempt to fix app restore issue

=> 4055d5b3012d6e0cbee965f2d1aa53caf991fd4f

diff --git a/src/app.c b/src/app.c
index 3b6752de..555206a9 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1000,6 +1000,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 22cf1fb0..cd8f2e12 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -515,15 +515,15 @@ void init_Window(iWindow *d, iRect rect) {
 
 void deinit_Window(iWindow *d) {
     iRecycle();
-    if (theWindow_ == d) {
-        theWindow_ = NULL;
-    }
     iForIndices(i, d->roots) {
         if (d->roots[i]) {
             setCurrent_Root(d->roots[i]);
             deinit_Root(d->roots[i]);
         }
     }
+    if (theWindow_ == d) {
+        theWindow_ = NULL;
+    }
     setCurrent_Root(NULL);
     delete_String(d->pendingSplitUrl);
     deinit_Text();
@@ -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;
@@ -1023,7 +1027,10 @@ void draw_Window(iWindow *d) {
     /* Clear the window. The clear color is visible as a border around the window
        when the custom frame is being used. */ {
 #if defined (iPlatformAppleMobile)
-        const iColor back = get_Color(tmBackground_ColorId);
+        iColor back = get_Color(uiBackground_ColorId);
+        if (deviceType_App() == phone_AppDeviceType) {
+            /* Page background extends to safe area, so fill it completely. */
+            back = get_Color(tmBackground_ColorId);
 #else
         const iColor back = get_Color(gotFocus && d->place.snap != maximized_WindowSnap &&
                                               ~winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.9/cdiff/4055d5b3012d6e0cbee965f2d1aa53caf991fd4f
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
64.174889 milliseconds
Gemini-to-HTML Time
0.472443 milliseconds

This content has been proxied by September (ba2dc).