]> git.mdlowis.com Git - proto/labwc.git/commitdiff
add MoveRelative
authorJulius Yli-Suomu <julle.ys.57@gmail.com>
Mon, 26 Jun 2023 16:04:33 +0000 (19:04 +0300)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 26 Jun 2023 18:37:58 +0000 (19:37 +0100)
src/action.c

index 9aef122bfe6e9507201757ea168795b368095145..d54c657a3e561d193da354ff45b2f8c4b8f788d3 100644 (file)
@@ -75,6 +75,7 @@ enum action_type {
        ACTION_TYPE_LOWER,
        ACTION_TYPE_RESIZE,
        ACTION_TYPE_MOVETO,
+       ACTION_TYPE_MOVE_RELATIVE,
        ACTION_TYPE_GO_TO_DESKTOP,
        ACTION_TYPE_SEND_TO_DESKTOP,
        ACTION_TYPE_SNAP_TO_REGION,
@@ -109,6 +110,7 @@ const char *action_names[] = {
        "Lower",
        "Resize",
        "MoveTo",
+       "MoveRelative",
        "GoToDesktop",
        "SendToDesktop",
        "SnapToRegion",
@@ -191,6 +193,7 @@ action_arg_from_xml_node(struct action *action, char *nodename, char *content)
                }
                break;
        case ACTION_TYPE_MOVETO:
+       case ACTION_TYPE_MOVE_RELATIVE:
                if (!strcmp(argument, "x") || !strcmp(argument, "y")) {
                        action_arg_add_int(action, argument, atoi(content));
                        goto cleanup;
@@ -607,6 +610,13 @@ actions_run(struct view *activator, struct server *server,
                                view_move(view, x, y);
                        }
                        break;
+               case ACTION_TYPE_MOVE_RELATIVE:
+                       if (view) {
+                               int x = get_arg_value_int(action, "x", 0);
+                               int y = get_arg_value_int(action, "y", 0);
+                               view_move(view, view->current.x + x, view->current.y + y);
+                       }
+                       break;
                case ACTION_TYPE_GO_TO_DESKTOP: {
                        const char *to = get_arg_value_str(action, "to", NULL);
                        if (!to) {