]> git.mdlowis.com Git - proto/labwc.git/commitdiff
action: add MoveTo
authorJohan Malm <jgm323@gmail.com>
Tue, 6 Jun 2023 19:33:53 +0000 (20:33 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 26 Jun 2023 05:04:07 +0000 (06:04 +0100)
docs/labwc-actions.5.scd
src/action.c

index cd9f3e278ca0a2ef65810ef71b9db30bdddbddbb..a31c77b84523a61dea1c0f4b0dff63b2ac110d8f 100644 (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".
index 12b878dcd269310b1096d0827e7e319605b57e10..9aef122bfe6e9507201757ea168795b368095145 100644 (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) {