Lagrange [work/v1.10]

Mobile: Fixed UI layout regressions

=> 22592e1ce3684671285dee7782213d9786c780cf

diff --git a/src/app.c b/src/app.c
index 366037dd..f2a7c5be 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2252,6 +2252,9 @@ static int resizeWatcher_(void *user, SDL_Event *event) {
 }
 
 iLocalDef iBool isResizeDrawEnabled_(void) {
+    if (isMobile_Platform()) {
+        return iFalse;
+    }
 #if defined (LAGRANGE_ENABLE_RESIZE_DRAW)
 #   if defined (LAGRANGE_ENABLE_X11_XLIB)
     if (!isXSession_X11()) {
diff --git a/src/ui/window.c b/src/ui/window.c
index 8c2a36ac..5b8b4da3 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1577,14 +1577,27 @@ void draw_MainWindow(iMainWindow *d) {
     setCurrent_Text(d->base.text);
     /* Check if root needs resizing. */ {
         const iBool wasPortrait = isPortrait_App();
-//        iInt2 renderSize;
-//        SDL_GetRendererOutputSize(w->render, &renderSize.x, &renderSize.y);
+#if defined (iPlatformMobile)
+        /* On a mobile device, the window doesn't get freely resized. The render size will
+           change when the device orientation changes. */
+        iInt2 renderSize;
+        SDL_GetRendererOutputSize(w->render, &renderSize.x, &renderSize.y);
+        if (!isEqual_I2(renderSize, w->size)) {
+            updateSize_MainWindow_(d, iTrue);
+            processEvents_App(postedEventsOnly_AppEventMode); /* apply changes immediately */
+            if (isPortrait_App() != wasPortrait) {
+                d->maxDrawableHeight = renderSize.y;
+            }
+        }
+#else
+        /* On the desktop, we cannot process events now because that would interfere with
+           regular input processing (currently drawing the window). */
         if (updateSize_MainWindow_(d, iTrue)) {
-            //processEvents_App(postedEventsOnly_AppEventMode);
             if (isPortrait_App() != wasPortrait) {
-                d->maxDrawableHeight = w->size.y; // renderSize.y;
+                d->maxDrawableHeight = w->size.y;
             }
         }
+#endif
         /* TODO: On macOS, a detached popup window will mess up the main window's rendering
            completely. Looks like a render target mixup. macOS builds normally use native menus,
            though, so leaving it in. */
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/22592e1ce3684671285dee7782213d9786c780cf
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
71.393893 milliseconds
Gemini-to-HTML Time
0.484154 milliseconds

This content has been proxied by September (ba2dc).