Lagrange [release]

Window/popup behavior improvements

=> 53df4b8f9b5d7cadf0874dbed99042f567afb66a

diff --git a/src/app.c b/src/app.c
index 1b071249..cf7619dc 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1591,7 +1591,7 @@ void processEvents_App(enum iAppEventMode eventMode) {
                     setCurrent_Window(window);
                     window->lastHover = window->hover;
                     wasUsed = processEvent_Window(window, &ev);
-                    if (ev.type == SDL_MOUSEMOTION || ev.type == SDL_MOUSEBUTTONDOWN) {
+                    if (ev.type == SDL_MOUSEMOTION) {
                         /* Only offered to the frontmost window. */
                         break;
                     }
diff --git a/src/ui/root.c b/src/ui/root.c
index 0967184c..1d1d2e61 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -319,6 +319,11 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
     if (equal_Command(cmd, "menu.open")) {
         iWidget *button = pointer_Command(cmd);
         iWidget *menu = findChild_Widget(button, "menu");
+        if (!menu) {
+            /* Independent popup window. */
+            postCommand_App("cancel");
+            return iTrue;
+        }
         const iBool isPlacedUnder = argLabel_Command(cmd, "under");
         iAssert(menu);
         if (!isVisible_Widget(menu)) {
@@ -327,7 +332,7 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
                                           : topLeft_Rect(bounds_Widget(button)));
         }
         else {
-            closeMenu_Widget(menu);
+            /* Already open, do nothing. */
         }
         return iTrue;
     }
@@ -1513,6 +1518,8 @@ void createUserInterface_Root(iRoot *d) {
         iLabelWidget *navMenu =
             makeMenuButton_LabelWidget(menu_Icon, navMenuItems_, iElemCount(navMenuItems_));
 #   endif
+        setFrameColor_Widget(findChild_Widget(as_Widget(navMenu), "menu"),
+                             uiSeparator_ColorId);
         setCommand_LabelWidget(navMenu, collectNewCStr_String("menu.open under:1"));
         setAlignVisually_LabelWidget(navMenu, iTrue);
         setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu");
diff --git a/src/ui/util.c b/src/ui/util.c
index 5cd24ce4..a45b1a5c 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -700,9 +700,6 @@ static iBool menuHandler_(iWidget *menu, const char *cmd) {
         }
         if ((equal_Command(cmd, "mouse.clicked") || equal_Command(cmd, "mouse.missed")) &&
             arg_Command(cmd)) {
-            if (hitChild_Window(get_Window(), coord_Command(cmd)) == parentMenuButton_(menu)) {
-                return iFalse;
-            }
             /* Dismiss open menus when clicking outside them. */
             closeMenu_Widget(menu);
             return iTrue;
diff --git a/src/ui/window.c b/src/ui/window.c
index 4c78b5fe..eb9021ad 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -840,7 +840,6 @@ static void savePlace_MainWindow_(iAny *mainWindow) {
     if (isNormalPlacement_MainWindow_(d)) {
         iInt2 newPos;
         SDL_GetWindowPosition(d->base.win, &newPos.x, &newPos.y);
-        printf("savePlace_MainWindow_ sets normalRect %d,%d\n", newPos.x, newPos.y); fflush(stdout);
         d->place.normalRect.pos = newPos;
         iInt2 border = zero_I2();
 #if !defined(iPlatformApple)
@@ -1136,6 +1135,9 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) {
                 wasUsed = dispatchEvent_Window(d, &event);
             }
             if (!wasUsed) {
+                if (event.type == SDL_MOUSEBUTTONDOWN) {
+                    closePopups_App(iFalse);
+                }
                 /* As a special case, clicking the middle mouse button can be used for pasting
                    from the clipboard. */
                 if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_MIDDLE) {
@@ -1264,8 +1266,7 @@ iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) {
         }
     }
     if (d->hover != oldHover) {
-        refresh_Widget(oldHover);
-        refresh_Widget(d->hover);
+        refresh_Widget(d->hover); /* Note: oldHover may have been deleted */
     }
     return wasUsed;
 }
@@ -1868,8 +1869,8 @@ int snap_MainWindow(const iMainWindow *d) {
 iWindow *newPopup_Window(iInt2 screenPos, iWidget *rootWidget) {
     start_PerfTimer(newPopup_Window);
     const iBool oldSw = forceSoftwareRender_App();
-    /* On macOS, SDL seems to want to not use HiDPI with software rendering. */
 #if !defined (iPlatformApple)
+    /* On macOS, SDL seems to want to not use HiDPI with software rendering. */
     setForceSoftwareRender_App(iTrue);
 #endif
     SDL_Rect usableRect;
@@ -1906,7 +1907,5 @@ iWindow *newPopup_Window(iInt2 screenPos, iWidget *rootWidget) {
 #if !defined (NDEBUG)
     stop_PerfTimer(newPopup_Window);
 #endif
-//    SDL_PumpEvents();
-//    processEvents_App(postedEventsOnly_AppEventMode);
     return win;
 }
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/release/cdiff/53df4b8f9b5d7cadf0874dbed99042f567afb66a
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
26.622151 milliseconds
Gemini-to-HTML Time
0.402188 milliseconds

This content has been proxied by September (ba2dc).