mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
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.
This commit is contained in:
parent
8f5217c98b
commit
fb5e85f40f
3 changed files with 13 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue