Lagrange [work/v1.8]

SidebarWidget: Never disable for context menu

=> 39ac9ed88e4a5b7bbd08b07ab700586c80752e11

diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index eae0432f..3d785e0a 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -106,7 +106,8 @@ struct Impl_SidebarWidget {
     size_t            numUnreadEntries;
     iWidget *         resizer;
     iWidget *         menu;
-    iSidebarItem *    contextItem; /* list item accessed in the context menu */
+    iSidebarItem *    contextItem;  /* list item accessed in the context menu */
+    size_t            contextIndex; /* index of list item accessed in the context menu */
 };
 
 iDefineObjectConstructionArgs(SidebarWidget, (enum iSidebarSide side), side)
@@ -644,6 +645,7 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
                  "actions");
     setBackgroundColor_Widget(d->actions, uiBackgroundSidebar_ColorId);
     d->contextItem = NULL;
+    d->contextIndex = iInvalidPos;
     d->blank = new_Widget();
     addChildFlags_Widget(content, iClob(d->blank), resizeChildren_WidgetFlag);
     addChildFlags_Widget(vdiv, iClob(content), expand_WidgetFlag);
@@ -844,7 +846,6 @@ iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *c
                                     isSelected_Widget(findChild_Widget(editor, "bmed.tag.linksplit")));
             postCommand_App("bookmarks.changed");
         }
-        setFlags_Widget(as_Widget(d), disabled_WidgetFlag, iFalse);
         destroy_Widget(editor);
         return iTrue;
     }
@@ -985,11 +986,8 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
             itemClicked_SidebarWidget_(d, pointerLabel_Command(cmd, "item"));
             return iTrue;
         }
-        else if (isCommand_Widget(w, ev, "menu.opened")) {
-            setFlags_Widget(as_Widget(d->list), disabled_WidgetFlag, iTrue);
-        }
         else if (isCommand_Widget(w, ev, "menu.closed")) {
-            setFlags_Widget(as_Widget(d->list), disabled_WidgetFlag, iFalse);
+         //   invalidateItem_ListWidget(d->list, d->contextIndex);
         }
         else if (isCommand_Widget(w, ev, "bookmark.open")) {
             const iSidebarItem *item = d->contextItem;
@@ -1010,7 +1008,6 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
         else if (isCommand_Widget(w, ev, "bookmark.edit")) {
             const iSidebarItem *item = d->contextItem;
             if (d->mode == bookmarks_SidebarMode && item) {
-                setFlags_Widget(w, disabled_WidgetFlag, iTrue);
                 iWidget *dlg = makeBookmarkEditor_Widget();
                 setId_Widget(dlg, format_CStr("bmed.%s", cstr_String(id_Widget(w))));
                 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
@@ -1038,7 +1035,6 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
         else if (isCommand_Widget(w, ev, "bookmark.dup")) {
             const iSidebarItem *item = d->contextItem;
             if (d->mode == bookmarks_SidebarMode && item) {
-                setFlags_Widget(w, disabled_WidgetFlag, iTrue);
                 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
                 const iBool isRemote = hasTag_Bookmark(bm, remote_BookmarkTag);
                 iChar icon = isRemote ? 0x1f588 : bm->icon;
@@ -1131,7 +1127,6 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
                         return iTrue;
                     }
                     if (isCommand_Widget(w, ev, "feed.entry.edit")) {
-                        setFlags_Widget(w, disabled_WidgetFlag, iTrue);
                         makeFeedSettings_Widget(id_Bookmark(feedBookmark));
                         return iTrue;
                     }
@@ -1307,6 +1302,10 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
                 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW);
             }
         }
+        if (d->contextIndex != iInvalidPos) {
+            invalidateItem_ListWidget(d->list, d->contextIndex);
+            d->contextIndex = iInvalidPos;
+        }
     }
     if (d->menu && ev->type == SDL_MOUSEBUTTONDOWN) {
         if (ev->button.button == SDL_BUTTON_RIGHT) {
@@ -1315,7 +1314,12 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
                 updateMouseHover_ListWidget(d->list);
             }
             if (constHoverItem_ListWidget(d->list) || isVisible_Widget(d->menu)) {
-                d->contextItem = hoverItem_ListWidget(d->list);
+                d->contextItem  = hoverItem_ListWidget(d->list);
+                /* Context is drawn in hover state. */
+                if (d->contextIndex != iInvalidPos) {
+                    invalidateItem_ListWidget(d->list, d->contextIndex);
+                }
+                d->contextIndex = hoverItemIndex_ListWidget(d->list);
                 /* Update menu items. */
                 /* TODO: Some callback-based mechanism would be nice for updating menus right
                    before they open? */
@@ -1436,9 +1440,13 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
                               const iListWidget *list) {
     const iSidebarWidget *sidebar = findParentClass_Widget(constAs_Widget(list),
                                                            &Class_SidebarWidget);
+    const iBool isMenuVisible = isVisible_Widget(sidebar->menu);
     const iBool isPressing   = isMouseDown_ListWidget(list);
-    const iBool isHover      = isHover_Widget(constAs_Widget(list)) &&
-                               constHoverItem_ListWidget(list) == d;
+    const iBool isHover      =
+            (!isMenuVisible &&
+            isHover_Widget(constAs_Widget(list)) &&
+            constHoverItem_ListWidget(list) == d) ||
+            (isMenuVisible && sidebar->contextItem == d);
     const int scrollBarWidth = scrollBarWidth_ListWidget(list);
 #if defined (iPlatformApple)
     const int blankWidth     = 0;
diff --git a/src/ui/util.c b/src/ui/util.c
index 92cf85b7..ac1540bb 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2493,11 +2493,6 @@ iWidget *makeBookmarkEditor_Widget(void) {
     return dlg;
 }
 
-static void enableSidebars_(void) {
-    setFlags_Widget(findWidget_App("sidebar"), disabled_WidgetFlag, iFalse);
-    setFlags_Widget(findWidget_App("sidebar2"), disabled_WidgetFlag, iFalse);
-}
-
 static iBool handleBookmarkCreationCommands_SidebarWidget_(iWidget *editor, const char *cmd) {
     if (equal_Command(cmd, "bmed.accept") || equal_Command(cmd, "cancel")) {
         if (equal_Command(cmd, "bmed.accept")) {
@@ -2522,8 +2517,6 @@ static iBool handleBookmarkCreationCommands_SidebarWidget_(iWidget *editor, cons
             postCommand_App("bookmarks.changed");
         }
         destroy_Widget(editor);
-        /* Sidebars are disabled when a dialog is opened. */
-        enableSidebars_();
         return iTrue;
     }
     return iFalse;
@@ -2553,8 +2546,6 @@ iWidget *makeBookmarkCreation_Widget(const iString *url, const iString *title, i
 static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) {
     if (equal_Command(cmd, "cancel")) {
         destroy_Widget(dlg);
-        /* Sidebars are disabled when a dialog is opened. */
-        enableSidebars_();
         return iTrue;
     }
     if (equal_Command(cmd, "feedcfg.accept")) {
@@ -2589,8 +2580,6 @@ static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) {
         }
         postCommand_App("bookmarks.changed");
         destroy_Widget(dlg);
-        /* Sidebars are disabled when a dialog is opened. */
-        enableSidebars_();
         return iTrue;
     }
     return iFalse;
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.8/cdiff/39ac9ed88e4a5b7bbd08b07ab700586c80752e11
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
76.575535 milliseconds
Gemini-to-HTML Time
0.636922 milliseconds

This content has been proxied by September (3851b).