From fb5e85f40ff92e68782665269529ecc187fcb2f2 Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sat, 8 Feb 2025 01:32:35 +0900 Subject: [PATCH] menu: remove ShowMenu action from menu items Previous commits fixed some unexpected behaviors when ShowMenu action is executed from menu items, but that was still prone to bugs because when calling actions_run(), we allow an inconsistent state where all menus are closed but pipemenus must not be destroyed. So this commit simply removes ShowMenu actions from menu items on initialization. --- include/action.h | 1 + src/action.c | 6 ++++++ src/menu/menu.c | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/action.h b/include/action.h index 7130d701..b8a271e9 100644 --- a/include/action.h +++ b/include/action.h @@ -23,6 +23,7 @@ struct action { struct action *action_create(const char *action_name); bool action_is_valid(struct action *action); +bool action_is_show_menu(struct action *action); void action_arg_add_str(struct action *action, const char *key, const char *value); void action_arg_add_actionlist(struct action *action, const char *key); diff --git a/src/action.c b/src/action.c index 21ce7bfe..3b03558c 100644 --- a/src/action.c +++ b/src/action.c @@ -606,6 +606,12 @@ action_is_valid(struct action *action) return false; } +bool +action_is_show_menu(struct action *action) +{ + return action->type == ACTION_TYPE_SHOW_MENU; +} + void action_free(struct action *action) { diff --git a/src/menu/menu.c b/src/menu/menu.c index ee1c66ef..54df18e2 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -115,7 +115,12 @@ validate_menu(struct menu *menu) struct action *action, *action_tmp; wl_list_for_each(item, &menu->menuitems, link) { wl_list_for_each_safe(action, action_tmp, &item->actions, link) { - if (!action_is_valid(action)) { + bool is_show_menu = action_is_show_menu(action); + if (!action_is_valid(action) || is_show_menu) { + if (is_show_menu) { + wlr_log(WLR_ERROR, "'ShowMenu' action is" + " not allowed in menu items"); + } wl_list_remove(&action->link); action_free(action); wlr_log(WLR_ERROR, "Removed invalid menu action"); -- 2.52.0