]> git.mdlowis.com Git - proto/labwc.git/commitdiff
action: add ResizeRelative
authorPh42oN <julle.ys.57@gmail.com>
Tue, 27 Jun 2023 18:20:04 +0000 (21:20 +0300)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 27 Jun 2023 18:59:33 +0000 (20:59 +0200)
docs/labwc-actions.5.scd
include/view.h
src/action.c
src/view.c

index e2ba6217bbb0ca3175f5f0b7258ddc4e44d1ddb5..1027096bcda600436ab9f8dd44b1686003af3177 100644 (file)
@@ -45,6 +45,11 @@ Actions are used in menus and keyboard/mouse bindings.
 *<action name="Resize">*
        Begin interactive resize of window under cursor
 
+*<action name="ResizeRelative" left="" right="" top="" bottom="" >*
+       Resize window relative to its current size. Values of left, right,
+       top or bottom tell how much to resize on that edge of window,
+       positive values grow window, negative shrink window.
+
 *<action name="MoveTo" x="" y="" />*
        Move to position (x, y)
 
index 3b3aeba8a1bb1a5ffb13c43c49242d03f5634f16..1a8e43148bc790937460ecce2828edfe2ef3422d 100644 (file)
@@ -153,6 +153,8 @@ void view_close(struct view *view);
  * For move only, use view_move()
  */
 void view_move_resize(struct view *view, struct wlr_box geo);
+void view_resize_relative(struct view *view,
+       int left, int right, int top, int bottom);
 void view_move(struct view *view, int x, int y);
 void view_moved(struct view *view);
 void view_minimize(struct view *view, bool minimized);
index 34305358be151a28383c58c6961608ea9245cd87..6dd370d0db24281a396938119a255ec8d0ebb669 100644 (file)
@@ -74,6 +74,7 @@ enum action_type {
        ACTION_TYPE_RAISE,
        ACTION_TYPE_LOWER,
        ACTION_TYPE_RESIZE,
+       ACTION_TYPE_RESIZE_RELATIVE,
        ACTION_TYPE_MOVETO,
        ACTION_TYPE_MOVE_RELATIVE,
        ACTION_TYPE_GO_TO_DESKTOP,
@@ -109,6 +110,7 @@ const char *action_names[] = {
        "Raise",
        "Lower",
        "Resize",
+       "ResizeRelative",
        "MoveTo",
        "MoveRelative",
        "GoToDesktop",
@@ -192,6 +194,13 @@ action_arg_from_xml_node(struct action *action, char *nodename, char *content)
                        goto cleanup;
                }
                break;
+       case ACTION_TYPE_RESIZE_RELATIVE:
+               if (!strcmp(argument, "left") || !strcmp(argument, "right") ||
+                               !strcmp(argument, "top") || !strcmp(argument, "bottom")) {
+                       action_arg_add_int(action, argument, atoi(content));
+                       goto cleanup;
+               }
+               break;
        case ACTION_TYPE_MOVETO:
        case ACTION_TYPE_MOVE_RELATIVE:
                if (!strcmp(argument, "x") || !strcmp(argument, "y")) {
@@ -603,6 +612,15 @@ actions_run(struct view *activator, struct server *server,
                                        resize_edges);
                        }
                        break;
+               case ACTION_TYPE_RESIZE_RELATIVE:
+                       if (view) {
+                               int left = get_arg_value_int(action, "left", 0);
+                               int right = get_arg_value_int(action, "right", 0);
+                               int top = get_arg_value_int(action, "top", 0);
+                               int bottom = get_arg_value_int(action, "bottom", 0);
+                               view_resize_relative(view, left, right, top, bottom);
+                       }
+                       break;
                case ACTION_TYPE_MOVETO:
                        if (view) {
                                int x = get_arg_value_int(action, "x", 0);
index 7b4592549893e34e79525b65c444d53d2d93561d..e22e264c7ac969a4bed7f609972edfc7f5bc2dec 100644 (file)
@@ -203,6 +203,17 @@ view_move_resize(struct view *view, struct wlr_box geo)
        }
 }
 
+void
+view_resize_relative(struct view *view, int left, int right, int top, int bottom)
+{
+       struct wlr_box newgeo = view->pending;
+       newgeo.x -= left;
+       newgeo.width += left + right;
+       newgeo.y -= top;
+       newgeo.height += top + bottom;
+       view_move_resize(view, newgeo);
+}
+
 void
 view_adjust_size(struct view *view, int *w, int *h)
 {