action: add MoveTo

This commit is contained in:
Johan Malm 2023-06-06 20:33:53 +01:00 committed by Johan Malm
parent 3a6a04215c
commit f6c3a3d7c3
2 changed files with 18 additions and 0 deletions

View file

@ -45,6 +45,9 @@ Actions are used in menus and keyboard/mouse bindings.
*<action name="Resize">*
Begin interactive resize of window under cursor
*<action name="MoveTo" x="" y="" />*
Move to position (x, y)
*<action name="SnapToEdge" direction="value" />*
Resize window to fill half the output in the given direction. Supports
directions "left", "up", "right", "down" and "center".

View file

@ -74,6 +74,7 @@ enum action_type {
ACTION_TYPE_RAISE,
ACTION_TYPE_LOWER,
ACTION_TYPE_RESIZE,
ACTION_TYPE_MOVETO,
ACTION_TYPE_GO_TO_DESKTOP,
ACTION_TYPE_SEND_TO_DESKTOP,
ACTION_TYPE_SNAP_TO_REGION,
@ -107,6 +108,7 @@ const char *action_names[] = {
"Raise",
"Lower",
"Resize",
"MoveTo",
"GoToDesktop",
"SendToDesktop",
"SnapToRegion",
@ -188,6 +190,12 @@ action_arg_from_xml_node(struct action *action, char *nodename, char *content)
goto cleanup;
}
break;
case ACTION_TYPE_MOVETO:
if (!strcmp(argument, "x") || !strcmp(argument, "y")) {
action_arg_add_int(action, argument, atoi(content));
goto cleanup;
}
break;
case ACTION_TYPE_SEND_TO_DESKTOP:
if (!strcmp(argument, "follow")) {
action_arg_add_bool(action, argument, parse_bool(content, true));
@ -592,6 +600,13 @@ actions_run(struct view *activator, struct server *server,
resize_edges);
}
break;
case ACTION_TYPE_MOVETO:
if (view) {
int x = get_arg_value_int(action, "x", 0);
int y = get_arg_value_int(action, "y", 0);
view_move(view, x, y);
}
break;
case ACTION_TYPE_GO_TO_DESKTOP: {
const char *to = get_arg_value_str(action, "to", NULL);
if (!to) {