diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd
index f3e6fb49..dc7e234d 100644
--- a/docs/labwc-actions.5.scd
+++ b/docs/labwc-actions.5.scd
@@ -70,11 +70,14 @@ Actions are used in menus and keyboard/mouse bindings.
*direction* [left|up|right|down] Direction in which to shrink.
-**
+**
Move focus to closest window in given direction.
*direction* [left|up|right|down] Direction in which to move.
+ *wrap* [yes|no] Wrap around from right-to-left or top-to-bottom,
+ and vice versa. Default no.
+
**
Move to position (x, y).
diff --git a/src/action.c b/src/action.c
index 1d764f43..f0ad0993 100644
--- a/src/action.c
+++ b/src/action.c
@@ -300,6 +300,12 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
goto cleanup;
}
break;
+ case ACTION_TYPE_DIRECTIONAL_TARGET_WINDOW:
+ if (!strcasecmp(argument, "wrap")) {
+ action_arg_add_bool(action, argument, parse_bool(content, false));
+ goto cleanup;
+ }
+ /* Falls through */
case ACTION_TYPE_MOVE_TO_EDGE:
if (!strcasecmp(argument, "snapWindows")) {
action_arg_add_bool(action, argument, parse_bool(content, true));
@@ -308,7 +314,6 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
/* Falls through */
case ACTION_TYPE_SNAP_TO_EDGE:
case ACTION_TYPE_GROW_TO_EDGE:
- case ACTION_TYPE_DIRECTIONAL_TARGET_WINDOW:
case ACTION_TYPE_SHRINK_TO_EDGE:
if (!strcmp(argument, "direction")) {
enum view_edge edge = view_edge_parse(content);
@@ -845,9 +850,11 @@ actions_run(struct view *activator, struct server *server,
break;
case ACTION_TYPE_DIRECTIONAL_TARGET_WINDOW:
if (view) {
+ /* Config parsing makes sure that direction is a valid direction */
enum view_edge direction = action_get_int(action, "direction", 0);
+ bool wrap = action_get_bool(action, "wrap", false);
struct view *closest_view = directional_target_window(view, server,
- direction, /*wrap*/ true);
+ direction, wrap);
if (closest_view) {
desktop_focus_view(closest_view, /*raise*/ true);
}