Lagrange [work/v1.6]

Improving overflow scrolling for desktop

=> bc2f7406f6e573c486cd3e6b7460ff13d1b9eba1

diff --git a/src/ui/root.c b/src/ui/root.c
index 7637d842..6f2868b7 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -2160,7 +2160,10 @@ iRect visibleRect_Root(const iRoot *d) {
 #endif
 #if defined (iPlatformDesktop)
     /* Apply the usable bounds of the display. */
-    SDL_Rect usable; {
+    SDL_Rect usable;
+    /* TODO: Needs some investigation. With multiple monitors, at least on macOS, the bounds
+       returned here seem incorrect sometimes (infrequently). */
+    if (iFalse) {
         const float ratio = d->window->pixelRatio;
         SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(d->window->win), &usable);
         iInt2 winPos;
diff --git a/src/ui/widget.c b/src/ui/widget.c
index addab9f0..ef2ac868 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -1291,19 +1291,25 @@ iBool scrollOverflow_Widget(iWidget *d, int delta) {
     }
     iRect       bounds        = boundsWithoutVisualOffset_Widget(d);
     const iRect winRect       = visibleRect_Root(d->root);
+    /* TODO: This needs some fixing on mobile, probably. */
+//    const int   yTop          = iMaxi(0, top_Rect(winRect));
+//    const int   yBottom       = bottom_Rect(winRect);
     iRangei     validPosRange = { bottom_Rect(winRect) - height_Rect(bounds),
                                   iMaxi(0, top_Rect(winRect)) };
-    if (validPosRange.start > validPosRange.end) {
-        validPosRange.start = validPosRange.end; /* no room to scroll */
-    }
+//    if (validPosRange.end < validPosRange.start) {
+//        validPosRange.end = validPosRange.start; /* no room to scroll */
+//    }
+//    if ((!isTopOver && delta < 0) || (!isBottomOver && delta > 0)) {
+//        delta = 0;
+//    }
     if (delta) {
-        if (delta < 0 && bounds.pos.y < validPosRange.start) {
-            delta = 0;
-        }
-        if (delta > 0 && bounds.pos.y > validPosRange.end) {
-            delta = 0;
-        }
-        //printf("delta:%d  validPosRange:%d...%d\n", delta, validPosRange.start, validPosRange.end); fflush(stdout);
+//        if (delta < 0 && bounds.pos.y < validPosRange.start) {
+//            delta = 0;
+//        }
+//        if (delta > 0 && bounds.pos.y > validPosRange.end) {
+//            delta = 0;
+//        }
+//        printf("delta:%d  validPosRange:%d...%d\n", delta, validPosRange.start, validPosRange.end); fflush(stdout);
         bounds.pos.y += delta;
         if (delta < 0) {
             bounds.pos.y = iMax(bounds.pos.y, validPosRange.start);
@@ -1316,7 +1322,10 @@ iBool scrollOverflow_Widget(iWidget *d, int delta) {
         }
     }
     else {
-        bounds.pos.y = iClamp(bounds.pos.y, validPosRange.start, validPosRange.end);
+        /* TODO: This is used on mobile. */
+        
+//        printf("clamping validPosRange:%d...%d\n", validPosRange.start, validPosRange.end); fflush(stdout);
+//        bounds.pos.y = iClamp(bounds.pos.y, validPosRange.start, validPosRange.end);
     }
     const iInt2 newPos = windowToInner_Widget(d->parent, bounds.pos);
     if (!isEqual_I2(newPos, d->rect.pos)) {
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.6/cdiff/bc2f7406f6e573c486cd3e6b7460ff13d1b9eba1
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
59.077251 milliseconds
Gemini-to-HTML Time
0.286399 milliseconds

This content has been proxied by September (ba2dc).