aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-06 15:37:55 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-04-06 15:37:55 -0400
commit9109b1fd119c6fbe1c4b5de3b97d948b86f81ce0 (patch)
treec7802860b4a4dfc0e6efbacf0745ab85ef48f972
parentAddress @emersion feedback (diff)
downloadsway-9109b1fd119c6fbe1c4b5de3b97d948b86f81ce0.tar.gz
sway-9109b1fd119c6fbe1c4b5de3b97d948b86f81ce0.tar.zst
sway-9109b1fd119c6fbe1c4b5de3b97d948b86f81ce0.zip
Fix moving to parallel container on another output
-rw-r--r--sway/tree/layout.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 7296423b..a3bee883 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -244,10 +244,7 @@ static int move_offs(enum movement_direction move_dir) {
244/* Gets the index of the most extreme member based on the movement offset */ 244/* Gets the index of the most extreme member based on the movement offset */
245static int container_limit(struct sway_container *container, 245static int container_limit(struct sway_container *container,
246 enum movement_direction move_dir) { 246 enum movement_direction move_dir) {
247 if (container->children->length == 0) { 247 return move_offs(move_dir) < 0 ? 0 : container->children->length;
248 return 0;
249 }
250 return move_offs(move_dir) < 0 ? 0 : container->children->length - 1;
251} 248}
252 249
253/* Takes one child, sets it aside, wraps the rest of the children in a new 250/* Takes one child, sets it aside, wraps the rest of the children in a new
@@ -306,7 +303,6 @@ void container_move(struct sway_container *container,
306 container_type_to_str(current->type), current->name); 303 container_type_to_str(current->type), current->name);
307 304
308 int index = index_child(current); 305 int index = index_child(current);
309 int limit = container_limit(parent, move_dir);
310 306
311 switch (current->type) { 307 switch (current->type) {
312 case C_OUTPUT: { 308 case C_OUTPUT: {
@@ -350,7 +346,8 @@ void container_move(struct sway_container *container,
350 case C_CONTAINER: 346 case C_CONTAINER:
351 case C_VIEW: 347 case C_VIEW:
352 if (is_parallel(parent->layout, move_dir)) { 348 if (is_parallel(parent->layout, move_dir)) {
353 if (index == limit) { 349 if ((index == parent->children->length - 1 && offs > 0)
350 || (index == 0 && offs < 0)) {
354 if (current->parent == container->parent) { 351 if (current->parent == container->parent) {
355 wlr_log(L_DEBUG, "Hit limit, selecting parent"); 352 wlr_log(L_DEBUG, "Hit limit, selecting parent");
356 current = current->parent; 353 current = current->parent;
@@ -408,7 +405,7 @@ void container_move(struct sway_container *container,
408 case C_CONTAINER: 405 case C_CONTAINER:
409 if (is_parallel(sibling->layout, move_dir)) { 406 if (is_parallel(sibling->layout, move_dir)) {
410 int limit = container_limit(sibling, invert_movement(move_dir)); 407 int limit = container_limit(sibling, invert_movement(move_dir));
411 limit = limit != 0 ? limit + 1 : limit; // Convert to index 408 wlr_log(L_DEBUG, "limit: %d", limit);
412 wlr_log(L_DEBUG, 409 wlr_log(L_DEBUG,
413 "Reparenting container (parallel) to index %d " 410 "Reparenting container (parallel) to index %d "
414 "(move dir: %d)", limit, move_dir); 411 "(move dir: %d)", limit, move_dir);