From: Johan Malm Date: Tue, 6 Jun 2023 19:33:53 +0000 (+0100) Subject: action: add MoveTo X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f6c3a3d7c3b75975ffbff00945d83d4ed038f079;p=proto%2Flabwc.git action: add MoveTo --- diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index cd9f3e27..a31c77b8 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -45,6 +45,9 @@ Actions are used in menus and keyboard/mouse bindings. ** Begin interactive resize of window under cursor +** + Move to position (x, y) + ** Resize window to fill half the output in the given direction. Supports directions "left", "up", "right", "down" and "center". diff --git a/src/action.c b/src/action.c index 12b878dc..9aef122b 100644 --- a/src/action.c +++ b/src/action.c @@ -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) {