]> git.mdlowis.com Git - proto/labwc.git/commitdiff
menu: assert no menu is opened in menu_open_root()
authortokyo4j <hrak1529@gmail.com>
Sat, 18 Jan 2025 04:09:47 +0000 (13:09 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 7 Feb 2025 16:58:55 +0000 (17:58 +0100)
66a3beb added an early-return when the menu is opened, so we can guarantee
that no menu is opened there.

src/menu/menu.c

index 1ddfd7ebc0cc4aaaab4f6a7068e2df7306497f19..ee1c66efd7477597209ac38203c8bd6b62291884 100644 (file)
@@ -1327,20 +1327,6 @@ menu_set_selection(struct menu *menu, struct menuitem *item)
        menu->selection.item = item;
 }
 
-static void
-close_all_submenus(struct menu *menu)
-{
-       struct menuitem *item;
-       wl_list_for_each(item, &menu->menuitems, link) {
-               if (item->submenu) {
-                       wlr_scene_node_set_enabled(
-                               &item->submenu->scene_tree->node, false);
-                       close_all_submenus(item->submenu);
-               }
-       }
-       menu->selection.menu = NULL;
-}
-
 /*
  * We only destroy pipemenus when closing the entire menu-tree so that pipemenu
  * are cached (for as long as the menu is open). This drastically improves the
@@ -1388,17 +1374,14 @@ menu_close(struct menu *menu)
 void
 menu_open_root(struct menu *menu, int x, int y)
 {
+       assert(menu);
+
        if (menu->server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
                return;
        }
 
-       assert(menu);
-       if (menu->server->menu_current) {
-               menu_close(menu->server->menu_current);
-               destroy_pipemenus(menu->server);
-       }
-       close_all_submenus(menu);
-       menu_set_selection(menu, NULL);
+       assert(!menu->server->menu_current);
+
        menu_configure(menu, (struct wlr_box){.x = x, .y = y});
        wlr_scene_node_set_enabled(&menu->scene_tree->node, true);
        menu->server->menu_current = menu;