action: add MoveTo

This commit is contained in:
Johan Malm 2023-06-06 20:33:53 +01:00
parent 6a7eb83465
commit 55400a1202
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">* *<action name="Resize">*
Begin interactive resize of window under cursor Begin interactive resize of window under cursor
*<action name="MoveTo" x="" y="" />*
Move to position (x, y)
*<action name="SnapToEdge" direction="value" />* *<action name="SnapToEdge" direction="value" />*
Resize window to fill half the output in the given direction. Supports Resize window to fill half the output in the given direction. Supports
directions "left", "up", "right", "down" and "center". directions "left", "up", "right", "down" and "center".

View file

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