Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions sway/commands/focus.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ 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, bool descend) {
enum wlr_direction dir, bool descend, bool visible_only) {
struct sway_container *wrap_candidate = NULL;
struct sway_container *current = container;
while (current) {
Expand All @@ -163,12 +163,14 @@ static struct sway_node *node_get_in_direction_tiling(
list_t *siblings = container_get_siblings(current);

if (dir == WLR_DIRECTION_LEFT || dir == WLR_DIRECTION_RIGHT) {
if (parent_layout == L_HORIZ || parent_layout == L_TABBED) {
if (parent_layout == L_HORIZ ||
(parent_layout == L_TABBED && !visible_only)) {
can_move = true;
desired = idx + (dir == WLR_DIRECTION_LEFT ? -1 : 1);
}
} else {
if (parent_layout == L_VERT || parent_layout == L_STACKED) {
if (parent_layout == L_VERT ||
(parent_layout == L_STACKED && !visible_only)) {
can_move = true;
desired = idx + (dir == WLR_DIRECTION_UP ? -1 : 1);
}
Expand Down Expand Up @@ -422,6 +424,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {

enum wlr_direction direction = 0;
bool descend = true;
bool visible_only = false;
if (!parse_direction(argv[0], &direction)) {
if (!get_direction_from_next_prev(container, seat, argv[0], &direction)) {
return cmd_results_new(CMD_INVALID,
Expand All @@ -431,6 +434,9 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
descend = false;
}
}
if (argc == 2 && strcasecmp(argv[1], "visible_only") == 0) {
visible_only = true;
}

if (!direction) {
return cmd_results_new(CMD_SUCCESS, NULL);
Expand Down Expand Up @@ -459,7 +465,8 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
container->pending.fullscreen_mode == FULLSCREEN_NONE) {
next_focus = node_get_in_direction_floating(container, seat, direction);
} else {
next_focus = node_get_in_direction_tiling(container, seat, direction, descend);
next_focus = node_get_in_direction_tiling(container, seat, direction,
descend, visible_only);
}
if (next_focus) {
seat_set_focus(seat, next_focus);
Expand Down
8 changes: 6 additions & 2 deletions sway/sway.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,12 @@ They are expected to be used with *bindsym* or at runtime through *swaymsg*(1).
<criteria> *focus*
Moves focus to the container that matches the specified criteria.

*focus* up|right|down|left
Moves focus to the next container in the specified direction.
*focus* up|right|down|left [visible_only]
Moves focus to the next container in the specified direction. With
_visible_only_, hidden windows inside tabbed or stacked containers are
skipped instead of being revealed, so focus lands on the nearest surface that
is already visible in that direction (a window, or another output's
workspace).

*focus* prev|next [sibling]
Moves focus to the previous or next container in the current layout. By default,
Expand Down