]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Fix crash when using _ToEdge actions when using the default keybinds
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 6 Aug 2023 07:47:37 +0000 (09:47 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 6 Aug 2023 08:37:36 +0000 (10:37 +0200)
This happens because of two separate bugs:
- The action validation failed to verify the data type of the argument
- When adding the fallback keybinds we add them as string but expect them being an int

This commit fixes the first bug.

Fixes 1ee8715d57ddb6b444e0b089879db6f837400539
actions: use enum for _ToEdge actions

src/action.c

index 900dcffc724c8577780043f50c4df5d276f3472d..35a29e7f15158e5f0269cf98d75d1730cdbf27f3 100644 (file)
@@ -257,13 +257,13 @@ action_str_from_arg(struct action_arg *arg)
 }
 
 static bool
-arg_value_exists(struct action *action, const char *key)
+arg_value_exists(struct action *action, const char *key, enum action_arg_type type)
 {
        assert(action);
        assert(key);
        struct action_arg *arg;
        wl_list_for_each(arg, &action->args, link) {
-               if (!strcasecmp(key, arg->key)) {
+               if (!strcasecmp(key, arg->key) && arg->type == type) {
                        return true;
                }
        }
@@ -373,6 +373,8 @@ bool
 action_is_valid(struct action *action)
 {
        const char *arg_name = NULL;
+       enum action_arg_type arg_type = LAB_ACTION_ARG_STR;
+
        switch (action->type) {
        case ACTION_TYPE_EXECUTE:
                arg_name = "command";
@@ -380,6 +382,7 @@ action_is_valid(struct action *action)
        case ACTION_TYPE_MOVE_TO_EDGE:
        case ACTION_TYPE_SNAP_TO_EDGE:
                arg_name = "direction";
+               arg_type = LAB_ACTION_ARG_INT;
                break;
        case ACTION_TYPE_SHOW_MENU:
                arg_name = "menu";
@@ -399,7 +402,7 @@ action_is_valid(struct action *action)
                return true;
        }
 
-       if (arg_value_exists(action, arg_name)) {
+       if (arg_value_exists(action, arg_name, arg_type)) {
                return true;
        }