aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-05-27 23:20:21 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-05-27 23:20:21 -0400
commit46da1dc32bd6c101964d32bb698e8187fb9ee91e (patch)
treee713b194254bf6d43214a394459c1b94e64bbacb /sway/tree/layout.c
parentMerge pull request #2050 from smlx/focus-fix (diff)
downloadsway-46da1dc32bd6c101964d32bb698e8187fb9ee91e.tar.gz
sway-46da1dc32bd6c101964d32bb698e8187fb9ee91e.tar.zst
sway-46da1dc32bd6c101964d32bb698e8187fb9ee91e.zip
Implement focus_wrapping
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 624d5516..6d76ae0f 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -708,7 +708,10 @@ struct sway_container *container_get_in_direction(
708 sway_output_from_wlr(wlr_adjacent); 708 sway_output_from_wlr(wlr_adjacent);
709 709
710 if (!adjacent || adjacent == container) { 710 if (!adjacent || adjacent == container) {
711 return wrap_candidate; 711 if (!wrap_candidate) {
712 return NULL;
713 }
714 return seat_get_focus_inactive_view(seat, wrap_candidate);
712 } 715 }
713 struct sway_container *next = 716 struct sway_container *next =
714 get_swayc_in_output_direction(adjacent, dir, seat); 717 get_swayc_in_output_direction(adjacent, dir, seat);
@@ -748,23 +751,25 @@ struct sway_container *container_get_in_direction(
748 if (desired < 0 || desired >= parent->children->length) { 751 if (desired < 0 || desired >= parent->children->length) {
749 can_move = false; 752 can_move = false;
750 int len = parent->children->length; 753 int len = parent->children->length;
751 if (!wrap_candidate && len > 1) { 754 if (config->focus_wrapping != WRAP_NO && !wrap_candidate
755 && len > 1) {
752 if (desired < 0) { 756 if (desired < 0) {
753 wrap_candidate = parent->children->items[len-1]; 757 wrap_candidate = parent->children->items[len-1];
754 } else { 758 } else {
755 wrap_candidate = parent->children->items[0]; 759 wrap_candidate = parent->children->items[0];
756 } 760 }
757 if (config->force_focus_wrapping) { 761 if (config->focus_wrapping == WRAP_FORCE) {
758 return wrap_candidate; 762 return seat_get_focus_inactive_view(seat,
763 wrap_candidate);
759 } 764 }
760 } 765 }
761 } else { 766 } else {
762 struct sway_container *desired_con = parent->children->items[desired]; 767 struct sway_container *desired_con =
768 parent->children->items[desired];
763 wlr_log(L_DEBUG, 769 wlr_log(L_DEBUG,
764 "cont %d-%p dir %i sibling %d: %p", idx, 770 "cont %d-%p dir %i sibling %d: %p", idx,
765 container, dir, desired, desired_con); 771 container, dir, desired, desired_con);
766 struct sway_container *next = seat_get_focus_inactive_view(seat, desired_con); 772 return seat_get_focus_inactive_view(seat, desired_con);
767 return next;
768 } 773 }
769 } 774 }
770 775
@@ -773,7 +778,10 @@ struct sway_container *container_get_in_direction(
773 parent = parent->parent; 778 parent = parent->parent;
774 if (!parent) { 779 if (!parent) {
775 // wrapping is the last chance 780 // wrapping is the last chance
776 return wrap_candidate; 781 if (!wrap_candidate) {
782 return NULL;
783 }
784 return seat_get_focus_inactive_view(seat, wrap_candidate);
777 } 785 }
778 } 786 }
779 } 787 }