diff options
author | 2016-10-07 07:10:06 +0200 | |
---|---|---|
committer | 2016-10-07 08:12:14 +0200 | |
commit | 7f558ce894934bd347140f5edd6419bf7d115c26 (patch) | |
tree | 8a52490b767be9b5ecb808ff5fa3c4486c5c30f5 /sway | |
parent | Merge pull request #934 from alkino/fix_click_title_bar (diff) | |
download | sway-7f558ce894934bd347140f5edd6419bf7d115c26.tar.gz sway-7f558ce894934bd347140f5edd6419bf7d115c26.tar.zst sway-7f558ce894934bd347140f5edd6419bf7d115c26.zip |
wrap container in direction (if possible)
Introduces container wrapping - if there is no other viable move, the
selection wraps on the first container where such action is possible.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/layout.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/sway/layout.c b/sway/layout.c index 6012af66..f10e21bd 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,18 @@ 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) { |
1112 | can_move = false; | 1116 | can_move = false; |
1117 | } else if (desired < 0 || desired >= parent->children->length) { | ||
1118 | can_move = false; | ||
1119 | int len = parent->children->length; | ||
1120 | if (!wrap_candidate && len > 1) { | ||
1121 | if (desired < 0) { | ||
1122 | wrap_candidate = parent->children->items[len-1]; | ||
1123 | } else { | ||
1124 | wrap_candidate = parent->children->items[0]; | ||
1125 | } | ||
1126 | } | ||
1113 | } else { | 1127 | } else { |
1114 | return parent->children->items[desired]; | 1128 | return parent->children->items[desired]; |
1115 | } | 1129 | } |
@@ -1118,8 +1132,8 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio | |||
1118 | container = parent; | 1132 | container = parent; |
1119 | parent = parent->parent; | 1133 | parent = parent->parent; |
1120 | if (!parent || container == limit) { | 1134 | if (!parent || container == limit) { |
1121 | // Nothing we can do | 1135 | // wrapping is the last chance |
1122 | return NULL; | 1136 | return wrap_candidate; |
1123 | } | 1137 | } |
1124 | } | 1138 | } |
1125 | } | 1139 | } |