From b633365db7bb8148116fa72bae4d05af754c28b6 Mon Sep 17 00:00:00 2001 From: Pavel Shramov Date: Sat, 11 May 2019 09:33:49 +0300 Subject: [PATCH] wip: focus: Forced wrapping variant Add "wrap" argument to focus DIR command to temporary enable forced wrapping. This is equivalent of 'focus_wrapping force; focus DIR; focus_wrapping yes' command --- sway/commands/focus.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 8baa616dd..a8cd3767b 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -93,9 +93,12 @@ static struct sway_node *get_node_in_output_direction( static struct sway_node *node_get_in_direction_tiling( struct sway_container *container, struct sway_seat *seat, - enum wlr_direction dir) { + enum wlr_direction dir, int force_wrap) { struct sway_container *wrap_candidate = NULL; struct sway_container *current = container; + enum focus_wrapping_mode focus_wrapping = config->focus_wrapping; + if (force_wrap) + focus_wrapping = WRAP_FORCE; while (current) { if (current->fullscreen_mode == FULLSCREEN_WORKSPACE) { // Fullscreen container with a direction - go straight to outputs @@ -133,14 +136,14 @@ static struct sway_node *node_get_in_direction_tiling( if (can_move) { if (desired < 0 || desired >= siblings->length) { int len = siblings->length; - if (config->focus_wrapping != WRAP_NO && !wrap_candidate + if (focus_wrapping != WRAP_NO && !wrap_candidate && len > 1) { if (desired < 0) { wrap_candidate = siblings->items[len-1]; } else { wrap_candidate = siblings->items[0]; } - if (config->focus_wrapping == WRAP_FORCE) { + if (focus_wrapping == WRAP_FORCE) { struct sway_container *c = seat_get_focus_inactive_view( seat, &wrap_candidate->node); return &c->node; @@ -353,6 +356,10 @@ struct cmd_results *cmd_focus(int argc, char **argv) { "or 'focus output '"); } + int force_wrap = 0; + if (argc > 1 && strcasecmp(argv[1], "wrap") == 0) + force_wrap = 1; + if (node->type == N_WORKSPACE) { // Jump to the next output struct sway_output *new_output = @@ -372,7 +379,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { if (container_is_floating(container)) { next_focus = node_get_in_direction_floating(container, seat, direction); } else { - next_focus = node_get_in_direction_tiling(container, seat, direction); + next_focus = node_get_in_direction_tiling(container, seat, direction, force_wrap); } if (next_focus) { seat_set_focus(seat, next_focus);