]> git.mdlowis.com Git - proto/labwc.git/commitdiff
menu: remove ShowMenu action from menu items
authortokyo4j <hrak1529@gmail.com>
Fri, 7 Feb 2025 16:32:35 +0000 (01:32 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 7 Feb 2025 16:58:55 +0000 (17:58 +0100)
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
src/action.c
src/menu/menu.c

index 7130d7011c230b78a1cdc02ad25a7a80ce7599ae..b8a271e99af71ac3c0f3cef932cdf004036db7f1 100644 (file)
@@ -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);
index 21ce7bfe083304f76a054c49a5077166f0b5704b..3b03558c7367c02b7f94204d45bea6cd81094d01 100644 (file)
@@ -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)
 {
index ee1c66efd7477597209ac38203c8bd6b62291884..54df18e2ddae0dff530be3a63feee6670df6abe6 100644 (file)
@@ -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");