Skip to content

Commit

Permalink
add force_focus_wrapping option
Browse files Browse the repository at this point in the history
  • Loading branch information
D.B committed Oct 7, 2016
1 parent 7f558ce commit d3f5ac8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sway/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ sway_cmd cmd_focus;
sway_cmd cmd_focus_follows_mouse;
sway_cmd cmd_font;
sway_cmd cmd_for_window;
sway_cmd cmd_force_focus_wrapping;
sway_cmd cmd_fullscreen;
sway_cmd cmd_gaps;
sway_cmd cmd_hide_edge_borders;
Expand Down
1 change: 1 addition & 0 deletions include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ struct sway_config {
// Flags
bool focus_follows_mouse;
bool mouse_warping;
bool force_focus_wrapping;
bool active;
bool failed;
bool reloading;
Expand Down
1 change: 1 addition & 0 deletions sway/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ static struct cmd_handler handlers[] = {
{ "focus", cmd_focus },
{ "focus_follows_mouse", cmd_focus_follows_mouse },
{ "font", cmd_font },
{ "force_focus_wrapping", cmd_force_focus_wrapping },
{ "for_window", cmd_for_window },
{ "fullscreen", cmd_fullscreen },
{ "gaps", cmd_gaps },
Expand Down
12 changes: 12 additions & 0 deletions sway/commands/force_focus_wrapping.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <string.h>
#include "sway/commands.h"

struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "force_focus_wrapping", EXPECTED_EQUAL_TO, 1))) {
return error;
}

config->force_focus_wrapping = !strcasecmp(argv[0], "yes");
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
3 changes: 3 additions & 0 deletions sway/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,9 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
} else {
wrap_candidate = parent->children->items[0];
}
if (config->force_focus_wrapping) {
return wrap_candidate;
}
}
} else {
return parent->children->items[desired];
Expand Down

0 comments on commit d3f5ac8

Please sign in to comment.