aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-06 12:46:33 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-04-06 12:46:33 -0400
commitcd6e3182fa55dd8ab3a8a167e854a5446baf39c7 (patch)
tree5dca00425dafb84085c5fe9febc2978a65c022a0
parentAddress @emersion's comments (diff)
downloadsway-cd6e3182fa55dd8ab3a8a167e854a5446baf39c7.tar.gz
sway-cd6e3182fa55dd8ab3a8a167e854a5446baf39c7.tar.zst
sway-cd6e3182fa55dd8ab3a8a167e854a5446baf39c7.zip
Fix issues @orestisf1993 raised
-rw-r--r--sway/debug-tree.c10
-rw-r--r--sway/tree/layout.c96
2 files changed, 57 insertions, 49 deletions
diff --git a/sway/debug-tree.c b/sway/debug-tree.c
index 08ee3585..aea6a8b1 100644
--- a/sway/debug-tree.c
+++ b/sway/debug-tree.c
@@ -34,12 +34,12 @@ static int draw_container(cairo_t *cairo, struct sway_container *container,
34 struct sway_container *focus, int x, int y) { 34 struct sway_container *focus, int x, int y) {
35 int text_width, text_height; 35 int text_width, text_height;
36 get_text_size(cairo, "monospace", &text_width, &text_height, 36 get_text_size(cairo, "monospace", &text_width, &text_height,
37 1, false, "%s '%s' %s %dx%d@%d,%d", 37 1, false, "%s id:%zd '%s' %s %dx%d@%d,%d",
38 container_type_to_str(container->type), container->name, 38 container_type_to_str(container->type), container->id, container->name,
39 layout_to_str(container->layout), 39 layout_to_str(container->layout),
40 container->width, container->height, container->x, container->y); 40 container->width, container->height, container->x, container->y);
41 cairo_rectangle(cairo, x, y, text_width, text_height); 41 cairo_rectangle(cairo, x, y, text_width, text_height);
42 cairo_set_source_u32(cairo, 0xFFFFFFFF); 42 cairo_set_source_u32(cairo, 0xFFFFFFE0);
43 cairo_fill(cairo); 43 cairo_fill(cairo);
44 cairo_move_to(cairo, x, y); 44 cairo_move_to(cairo, x, y);
45 if (focus == container) { 45 if (focus == container) {
@@ -47,8 +47,8 @@ static int draw_container(cairo_t *cairo, struct sway_container *container,
47 } else { 47 } else {
48 cairo_set_source_u32(cairo, 0x000000FF); 48 cairo_set_source_u32(cairo, 0x000000FF);
49 } 49 }
50 pango_printf(cairo, "monospace", 1, false, "%s '%s' %s %dx%d@%d,%d", 50 pango_printf(cairo, "monospace", 1, false, "%s id:%zd '%s' %s %dx%d@%d,%d",
51 container_type_to_str(container->type), container->name, 51 container_type_to_str(container->type), container->id, container->name,
52 layout_to_str(container->layout), 52 layout_to_str(container->layout),
53 container->width, container->height, container->x, container->y); 53 container->width, container->height, container->x, container->y);
54 int height = text_height; 54 int height = text_height;
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 1c31b215..a0586f40 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -381,53 +381,61 @@ void container_move(struct sway_container *container,
381 int index = index_child(container); 381 int index = index_child(container);
382 struct sway_container *old_parent = container->parent; 382 struct sway_container *old_parent = container->parent;
383 383
384 switch (sibling->type) { 384 while (sibling) {
385 case C_VIEW: 385 switch (sibling->type) {
386 if (sibling->parent == container->parent) { 386 case C_VIEW:
387 wlr_log(L_DEBUG, "Swapping siblings"); 387 if (sibling->parent == container->parent) {
388 sibling->parent->children->items[index + offs] = container; 388 wlr_log(L_DEBUG, "Swapping siblings");
389 sibling->parent->children->items[index] = sibling; 389 sibling->parent->children->items[index + offs] = container;
390 arrange_windows(sibling->parent, -1, -1); 390 sibling->parent->children->items[index] = sibling;
391 } else { 391 arrange_windows(sibling->parent, -1, -1);
392 wlr_log(L_DEBUG, "Promoting to sibling of cousin");
393 container_insert_child(sibling->parent, container,
394 index_child(sibling) + (offs > 0 ? 0 : 1));
395 container->width = container->height = 0;
396 arrange_windows(sibling->parent, -1, -1);
397 arrange_windows(old_parent, -1, -1);
398 }
399 break;
400 case C_WORKSPACE: // Note: only in the case of moving between outputs
401 case C_CONTAINER:
402 if (is_parallel(sibling->layout, move_dir)) {
403 int limit = container_limit(sibling, move_dir);
404 wlr_log(L_DEBUG, "Reparenting container (paralell)");
405 limit = limit != 0 ? limit + 1 : limit; // Convert to index
406 container_insert_child(sibling, container, limit);
407 container->width = container->height = 0;
408 arrange_windows(sibling, -1, -1);
409 arrange_windows(old_parent, -1, -1);
410 } else {
411 wlr_log(L_DEBUG, "Reparenting container (perpendicular)");
412 container_remove_child(container);
413 struct sway_container *focus_inactive = seat_get_focus_inactive(
414 config->handler_context.seat, sibling);
415 if (focus_inactive) {
416 container_add_sibling(focus_inactive, container);
417 } else if (sibling->children->length) {
418 container_add_sibling(sibling->children->items[0], container);
419 } else { 392 } else {
420 container_add_child(sibling, container); 393 wlr_log(L_DEBUG, "Promoting to sibling of cousin");
394 container_insert_child(sibling->parent, container,
395 index_child(sibling) + (offs > 0 ? 0 : 1));
396 container->width = container->height = 0;
397 arrange_windows(sibling->parent, -1, -1);
398 arrange_windows(old_parent, -1, -1);
421 } 399 }
422 container->width = container->height = 0; 400 sibling = NULL;
423 arrange_windows(sibling, -1, -1); 401 break;
424 arrange_windows(old_parent, -1, -1); 402 case C_WORKSPACE: // Note: only in the case of moving between outputs
403 case C_CONTAINER:
404 if (is_parallel(sibling->layout, move_dir)) {
405 int limit = container_limit(sibling, move_dir);
406 wlr_log(L_DEBUG, "Reparenting container (paralell)");
407 limit = limit != 0 ? limit + 1 : limit; // Convert to index
408 container_insert_child(sibling, container, limit);
409 container->width = container->height = 0;
410 arrange_windows(sibling, -1, -1);
411 arrange_windows(old_parent, -1, -1);
412 sibling = NULL;
413 } else {
414 wlr_log(L_DEBUG, "Reparenting container (perpendicular)");
415 container_remove_child(container);
416 struct sway_container *focus_inactive = seat_get_focus_inactive(
417 config->handler_context.seat, sibling);
418 wlr_log(L_DEBUG, "Focus inactive: %zd", focus_inactive ?
419 focus_inactive->id : 0);
420 if (focus_inactive) {
421 sibling = focus_inactive;
422 continue;
423 } else if (sibling->children->length) {
424 container_add_sibling(sibling->children->items[0], container);
425 } else {
426 container_add_child(sibling, container);
427 }
428 container->width = container->height = 0;
429 arrange_windows(sibling, -1, -1);
430 arrange_windows(old_parent, -1, -1);
431 sibling = NULL;
432 }
433 break;
434 default:
435 sway_assert(0, "Not expecting to see container of type %s here",
436 container_type_to_str(sibling->type));
437 return;
425 } 438 }
426 break;
427 default:
428 sway_assert(0, "Not expecting to see container of type %s here",
429 container_type_to_str(sibling->type));
430 return;
431 } 439 }
432 440
433 if (old_parent) { 441 if (old_parent) {