From a0cebb7c5a0530414e85c85fb0231881f988df7c Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Fri, 1 Apr 2016 21:39:15 +0200 Subject: [PATCH] Improve move command with tabbed/stacked layout --- sway/debug_log.c | 1 + sway/layout.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sway/debug_log.c b/sway/debug_log.c index 761dca6c..f804a541 100644 --- a/sway/debug_log.c +++ b/sway/debug_log.c @@ -38,6 +38,7 @@ static void container_log(const swayc_t *c, int depth) { c->layout == L_HORIZ ? "Horiz": c->layout == L_VERT ? "Vert": c->layout == L_STACKED ? "Stack": + c->layout == L_TABBED ? "Tab": c->layout == L_FLOATING ? "Float": "Unknown"); fprintf(stderr, "w:%4.f|h:%4.f|", c->width, c->height); diff --git a/sway/layout.c b/sway/layout.c index 261e2138..e9eb8add 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -244,7 +244,9 @@ void move_container(swayc_t *container, enum movement_direction dir) { while (true) { sway_log(L_DEBUG, "container:%p, parent:%p, child %p,", container,parent,child); - if (parent->layout == layout) { + if (parent->layout == layout + || (parent->layout == L_TABBED && layout == L_HORIZ) + || (parent->layout == L_STACKED && layout == L_VERT)) { int diff; // If it has ascended (parent has moved up), no container is removed // so insert it at index, or index+1. @@ -264,9 +266,11 @@ void move_container(swayc_t *container, enum movement_direction dir) { // Move container into sibling container if (child->type == C_CONTAINER) { parent = child; - // Insert it in first/last if matching layout,otherwise + // Insert it in first/last if matching layout, otherwise // inesrt it next to focused container - if (parent->layout == layout) { + if (parent->layout == layout + || (parent->layout == L_TABBED && layout == L_HORIZ) + || (parent->layout == L_STACKED && layout == L_VERT)) { desired = (diff < 0) * parent->children->length; } else { desired = index_child(child->focused); @@ -300,7 +304,7 @@ void move_container(swayc_t *container, enum movement_direction dir) { parent = child->parent; } // Dirty hack to fix a certain case - arrange_windows(parent, -1, -1); + /* arrange_windows(parent, -1, -1); */ arrange_windows(parent->parent, -1, -1); set_focused_container_for(parent->parent, container); }