From a0e22d5e072f12b4c37ebd727168494f1b42d7c1 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Mon, 4 Jul 2022 00:33:35 +0200 Subject: [PATCH] [wip] src/action.c: Add action_arg_box --- include/action.h | 2 ++ include/private/action.h | 6 ++++++ src/action.c | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/include/action.h b/include/action.h index e5506033..1a45fa92 100644 --- a/include/action.h +++ b/include/action.h @@ -5,6 +5,7 @@ struct view; struct server; struct wl_list; +struct wlr_box; struct action { struct wl_list link; /* struct keybinding.actions, @@ -17,6 +18,7 @@ struct action { struct action *action_create(const char *action_name); void action_arg_add_str(struct action *action, char *key, const char *value); +struct wlr_box *action_arg_add_box(struct action *action, char *name); void actions_run(struct view *activator, struct server *server, struct wl_list *actions, uint32_t resize_edges); void action_list_free(struct wl_list *action_list); diff --git a/include/private/action.h b/include/private/action.h index 0b8f60d0..e58ee666 100644 --- a/include/private/action.h +++ b/include/private/action.h @@ -7,6 +7,7 @@ enum action_arg_type { LAB_ACTION_ARG_STR = 0, + LAB_ACTION_ARG_BOX, }; struct action_arg { @@ -21,4 +22,9 @@ struct action_arg_str { char *value; }; +struct action_arg_box { + struct action_arg base; + struct wlr_box value; +}; + #endif /* __LABWC_PRIVATE_ACTION_H */ diff --git a/src/action.c b/src/action.c index 3b6dd4d4..15970df1 100644 --- a/src/action.c +++ b/src/action.c @@ -73,6 +73,13 @@ action_str_from_arg(struct action_arg *arg) return ((struct action_arg_str *)arg)->value; } +static struct wlr_box * +action_box_from_arg(struct action_arg *arg) +{ + assert(arg->type == LAB_ACTION_ARG_BOX); + return &((struct action_arg_box *)arg)->value; +} + static struct action_arg * action_get_first_arg(struct action *action) { @@ -357,3 +364,15 @@ action_arg_add_str(struct action *action, char *key, const char *value) arg->value = strdup(value); wl_list_insert(action->args.prev, &arg->base.link); } + +struct wlr_box * +action_arg_add_box(struct action *action, char *name) +{ + struct action_arg_box *arg = calloc(1, sizeof(*arg)); + arg->base.type = LAB_ACTION_ARG_BOX; + if (name) { + arg->base.key = strdup(name); + } + wl_list_insert(action->args.prev, &arg->base.link); + return &arg->value; +}