]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add directional options to `Resize` action:
authorMaik Broemme <mbroemme@libmpq.org>
Fri, 28 Nov 2025 19:51:00 +0000 (20:51 +0100)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Wed, 3 Dec 2025 18:01:27 +0000 (03:01 +0900)
This introduces an optional "direction" argument to the Resize action,
mirroring Fluxbox's StartResizing [corner] behavior.

Supported values (case-insensitive) are:
up-left, up, up-right, left, right, down-left, down, down-right.

If no direction is specified, the existing behavior is preserved and the
resize edges are inferred from the current pointer position. The action
documentation has been updated to describe the new argument.

docs/labwc-actions.5.scd
src/action.c

index 4a76a374deabd960ab69f1cb009ff6465cbec11a..96e44cb620dd3e9c090c17657a04aaa89bbbd23c 100644 (file)
@@ -51,9 +51,13 @@ Actions are used in menus and keyboard/mouse bindings.
        another window or screen edge. If set to "no", only move to
        the next screen edge. Default is yes.
 
-*<action name="Resize" />*
+*<action name="Resize" direction="value" />*
        Begin interactive resize of window under cursor.
 
+       *direction* [up|down|left|right|up-left|up-right|down-left|down-right]
+       Edge or corner from which to start resizing. If this is not provided,
+       the direction is inferred from the cursor position.
+
 *<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,
index ceeffd67802b456791357e8d9fc990d4c33c1a16..7ddba0bee774af2f9acb9f52b04650afd7c909bb 100644 (file)
@@ -414,6 +414,20 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
                        goto cleanup;
                }
                break;
+       case ACTION_TYPE_RESIZE:
+               if (!strcmp(argument, "direction")) {
+                       enum lab_edge edge = lab_edge_parse(content,
+                               /*tiled*/ true, /*any*/ false);
+                       if (edge == LAB_EDGE_NONE || edge == LAB_EDGE_CENTER) {
+                               wlr_log(WLR_ERROR,
+                                       "Invalid argument for action %s: '%s' (%s)",
+                                       action_names[action->type], argument, content);
+                       } else {
+                               action_arg_add_int(action, argument, edge);
+                       }
+                       goto cleanup;
+               }
+               break;
        case ACTION_TYPE_RESIZE_RELATIVE:
                if (!strcmp(argument, "left") || !strcmp(argument, "right") ||
                                !strcmp(argument, "top") || !strcmp(argument, "bottom")) {
@@ -1223,8 +1237,17 @@ run_action(struct view *view, struct server *server, struct action *action,
                break;
        case ACTION_TYPE_RESIZE:
                if (view) {
-                       enum lab_edge resize_edges = cursor_get_resize_edges(
-                               server->seat.cursor, ctx);
+                       /*
+                        * If a direction was specified in the config, honour it.
+                        * Otherwise, fall back to determining the resize edges from
+                        * the current cursor position (existing behaviour).
+                        */
+                       enum lab_edge resize_edges =
+                               action_get_int(action, "direction", LAB_EDGE_NONE);
+                       if (resize_edges == LAB_EDGE_NONE) {
+                               resize_edges = cursor_get_resize_edges(
+                                       server->seat.cursor, ctx);
+                       }
                        interactive_begin(view, LAB_INPUT_STATE_RESIZE,
                                resize_edges);
                }