view: add MoveToOutput wrap attribute

Support `wrap` in view_get_adjacent_output(). This means that when seeking
an adjacent output in a particular direction from an output that is
already furthest in that direction within the layout, rather than
returning NULL, wrap around from the leftmost to the rightmost, or topmost
to the bottommost and vice versa.

Example usage:

    <action name="MoveToOutput" direction="right" wrap="yes" />

Wrap is disabled by default to keep the user interface consistent.
This commit is contained in:
Johan Malm 2024-03-02 15:42:05 +00:00 committed by Johan Malm
parent 7e338fc365
commit 3c3bcc2765
4 changed files with 69 additions and 27 deletions

View file

@ -397,6 +397,10 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
}
goto cleanup;
}
if (!strcmp(argument, "wrap")) {
action_arg_add_bool(action, argument, parse_bool(content, false));
goto cleanup;
}
break;
case ACTION_TYPE_VIRTUAL_OUTPUT_ADD:
case ACTION_TYPE_VIRTUAL_OUTPUT_REMOVE:
@ -924,7 +928,8 @@ actions_run(struct view *activator, struct server *server,
} else {
/* Config parsing makes sure that direction is a valid direction */
enum view_edge edge = action_get_int(action, "direction", 0);
target = view_get_adjacent_output(view, edge);
bool wrap = action_get_bool(action, "wrap", false);
target = view_get_adjacent_output(view, edge, wrap);
}
if (!target) {
wlr_log(WLR_ERROR, "Invalid output.");