diff options
Diffstat (limited to 'sway/layout.c')
-rw-r--r-- | sway/layout.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/sway/layout.c b/sway/layout.c index 6012af66..3629df24 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -1084,13 +1084,17 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio | |||
1084 | return container->fullscreen; | 1084 | return container->fullscreen; |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | swayc_t *wrap_candidate = NULL; | ||
1087 | while (true) { | 1088 | while (true) { |
1088 | // Test if we can even make a difference here | 1089 | // Test if we can even make a difference here |
1089 | bool can_move = false; | 1090 | bool can_move = false; |
1090 | int diff = 0; | 1091 | int diff = 0; |
1091 | if (parent->type == C_ROOT) { | 1092 | if (parent->type == C_ROOT) { |
1092 | sway_log(L_DEBUG, "Moving between outputs"); | ||
1093 | swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true); | 1093 | swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true); |
1094 | if (!output || output == container) { | ||
1095 | return wrap_candidate; | ||
1096 | } | ||
1097 | sway_log(L_DEBUG, "Moving between outputs"); | ||
1094 | return get_swayc_in_output_direction(output, dir); | 1098 | return get_swayc_in_output_direction(output, dir); |
1095 | } else { | 1099 | } else { |
1096 | if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { | 1100 | if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { |
@@ -1108,8 +1112,31 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio | |||
1108 | 1112 | ||
1109 | if (can_move) { | 1113 | if (can_move) { |
1110 | int desired = index_child(container) + diff; | 1114 | int desired = index_child(container) + diff; |
1111 | if (container->is_floating || desired < 0 || desired >= parent->children->length) { | 1115 | if (container->is_floating) { |
1116 | if (desired < 0) { | ||
1117 | wrap_candidate = parent->floating->items[parent->floating->length-1]; | ||
1118 | } else if (desired >= parent->floating->length){ | ||
1119 | wrap_candidate = parent->floating->items[0]; | ||
1120 | } else { | ||
1121 | wrap_candidate = parent->floating->items[desired]; | ||
1122 | } | ||
1123 | if (wrap_candidate) { | ||
1124 | wlc_view_bring_to_front(wrap_candidate->handle); | ||
1125 | } | ||
1126 | return wrap_candidate; | ||
1127 | } else if (desired < 0 || desired >= parent->children->length) { | ||
1112 | can_move = false; | 1128 | can_move = false; |
1129 | int len = parent->children->length; | ||
1130 | if (!wrap_candidate && len > 1) { | ||
1131 | if (desired < 0) { | ||
1132 | wrap_candidate = parent->children->items[len-1]; | ||
1133 | } else { | ||
1134 | wrap_candidate = parent->children->items[0]; | ||
1135 | } | ||
1136 | if (config->force_focus_wrapping) { | ||
1137 | return wrap_candidate; | ||
1138 | } | ||
1139 | } | ||
1113 | } else { | 1140 | } else { |
1114 | return parent->children->items[desired]; | 1141 | return parent->children->items[desired]; |
1115 | } | 1142 | } |
@@ -1118,8 +1145,8 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio | |||
1118 | container = parent; | 1145 | container = parent; |
1119 | parent = parent->parent; | 1146 | parent = parent->parent; |
1120 | if (!parent || container == limit) { | 1147 | if (!parent || container == limit) { |
1121 | // Nothing we can do | 1148 | // wrapping is the last chance |
1122 | return NULL; | 1149 | return wrap_candidate; |
1123 | } | 1150 | } |
1124 | } | 1151 | } |
1125 | } | 1152 | } |