From 3ee3a9ef60c6259720564bbedb0c74d545d2ec53 Mon Sep 17 00:00:00 2001 From: lbonn Date: Wed, 16 Oct 2019 20:27:19 +0200 Subject: [PATCH] focus: support focus_wrapping workspace Following i3 support: https://github.com/i3/i3/pull/3407 --- include/sway/config.h | 3 ++- sway/commands/focus.c | 3 ++- sway/commands/focus_wrapping.c | 2 ++ sway/sway.5.scd | 6 ++++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 0031db429..632027ead 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -409,7 +409,8 @@ enum focus_follows_mouse_mode { enum focus_wrapping_mode { WRAP_NO, WRAP_YES, - WRAP_FORCE + WRAP_FORCE, + WRAP_WORKSPACE }; enum mouse_warping_mode { diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 8baa616dd..93d1effef 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -160,7 +160,8 @@ static struct sway_node *node_get_in_direction_tiling( // Check a different output struct sway_output *output = container->workspace->output; struct sway_output *new_output = output_get_in_direction(output, dir); - if (new_output) { + if ((config->focus_wrapping != WRAP_WORKSPACE || + container->node.type == N_WORKSPACE) && new_output) { return get_node_in_output_direction(new_output, dir); } diff --git a/sway/commands/focus_wrapping.c b/sway/commands/focus_wrapping.c index 3a74a3ea5..d3901cb8f 100644 --- a/sway/commands/focus_wrapping.c +++ b/sway/commands/focus_wrapping.c @@ -11,6 +11,8 @@ struct cmd_results *cmd_focus_wrapping(int argc, char **argv) { if (strcasecmp(argv[0], "force") == 0) { config->focus_wrapping = WRAP_FORCE; + } else if (strcasecmp(argv[0], "workspace") == 0) { + config->focus_wrapping = WRAP_WORKSPACE; } else if (parse_boolean(argv[0], config->focus_wrapping == WRAP_YES)) { config->focus_wrapping = WRAP_YES; } else { diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 7c73a2550..63b5465ad 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -551,14 +551,16 @@ The default colors are: If set to _smart_, the window will become focused only if it is already visible, otherwise the urgent state will be set. Default is _smart_. -*focus_wrapping* yes|no|force +*focus_wrapping* yes|no|force|workspace This option determines what to do when attempting to focus over the edge of a container. If set to _no_, the focused container will retain focus, if there are no other containers in the direction. If set to _yes_, focus will be wrapped to the opposite edge of the container, if there are no other containers in the direction. If set to _force_, focus will be wrapped to the opposite edge of the container, even if there are other containers - in the direction. Default is _yes_. + in the direction. If set to _workspace_, focus will wrap like in the _yes_ + case and additionally wrap when moving outside of workspaces boundaries. + Default is _yes_. *font* [pango:] Sets font to use for the title bars. To enable support for pango markup,