From 8aef255d5f69751dfdfbd3bc18e94507d1a004cd Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Tue, 24 Nov 2015 20:46:22 +0100 Subject: [PATCH 1/4] layout: add_sibling: Handle floating views properly. This should fix #241. --- sway/layout.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sway/layout.c b/sway/layout.c index 741addf1..a50f541c 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -88,12 +88,16 @@ void add_floating(swayc_t *ws, swayc_t *child) { } } -swayc_t *add_sibling(swayc_t *sibling, swayc_t *child) { - swayc_t *parent = sibling->parent; - int i = index_child(sibling); - list_insert(parent->children, i+1, child); - child->parent = parent; - return child->parent; +swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) { + swayc_t *parent = fixed->parent; + int i = index_child(fixed); + if (fixed->is_floating) { + list_insert(parent->floating, i + 1, active); + } else { + list_insert(parent->children, i + 1, active); + } + active->parent = parent; + return active->parent; } swayc_t *replace_child(swayc_t *child, swayc_t *new_child) { From ed1b0bffbce318327fd00987bc0a075d6ebbc10a Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Tue, 24 Nov 2015 20:57:41 +0100 Subject: [PATCH 2/4] layout: replace_child: Handle floating views. --- sway/layout.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sway/layout.c b/sway/layout.c index a50f541c..23d99e35 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -106,8 +106,11 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) { return NULL; } int i = index_child(child); - parent->children->items[i] = new_child; - + if (child->is_floating) { + parent->floating->items[i] = new_child; + } else { + parent->children->items[i] = new_child; + } // Set parent and focus for new_child new_child->parent = child->parent; if (child->parent->focused == child) { From b5ddad4bf64c3541ab765c56f84a90842c2d4512 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Tue, 24 Nov 2015 20:58:02 +0100 Subject: [PATCH 3/4] layout: swap_container: Handle floating views. --- sway/layout.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sway/layout.c b/sway/layout.c index 23d99e35..ac56f7b2 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -174,7 +174,6 @@ swayc_t *remove_child(swayc_t *child) { } void swap_container(swayc_t *a, swayc_t *b) { - //TODO doesnt handle floating <-> tiling swap if (!sway_assert(a&&b, "parameters must be non null") || !sway_assert(a->parent && b->parent, "containers must have parents")) { return; @@ -184,8 +183,16 @@ void swap_container(swayc_t *a, swayc_t *b) { swayc_t *a_parent = a->parent; swayc_t *b_parent = b->parent; // Swap the pointers - a_parent->children->items[a_index] = b; - b_parent->children->items[b_index] = a; + if (a->is_floating) { + a_parent->floating->items[a_index] = b; + } else { + a_parent->children->items[a_index] = b; + } + if (b->is_floating) { + b_parent->floating->items[b_index] = a; + } else { + b_parent->children->items[b_index] = a; + } a->parent = b_parent; b->parent = a_parent; if (a_parent->focused == a) { From e31a899841c88613235f319d5a852fe8a4d1711a Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Tue, 24 Nov 2015 20:58:17 +0100 Subject: [PATCH 4/4] layout: get_swayc_in_direction_under: Handle floating views. --- sway/layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/layout.c b/sway/layout.c index ac56f7b2..de186886 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -574,7 +574,7 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio if (can_move) { int desired = index_child(container) + diff; - if (desired < 0 || desired >= parent->children->length) { + if (container->is_floating || desired < 0 || desired >= parent->children->length) { can_move = false; } else { return parent->children->items[desired];