diff options
-rw-r--r-- | sway/layout.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/sway/layout.c b/sway/layout.c index 741addf1..de186886 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -88,12 +88,16 @@ void add_floating(swayc_t *ws, swayc_t *child) { | |||
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | swayc_t *add_sibling(swayc_t *sibling, swayc_t *child) { | 91 | swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) { |
92 | swayc_t *parent = sibling->parent; | 92 | swayc_t *parent = fixed->parent; |
93 | int i = index_child(sibling); | 93 | int i = index_child(fixed); |
94 | list_insert(parent->children, i+1, child); | 94 | if (fixed->is_floating) { |
95 | child->parent = parent; | 95 | list_insert(parent->floating, i + 1, active); |
96 | return child->parent; | 96 | } else { |
97 | list_insert(parent->children, i + 1, active); | ||
98 | } | ||
99 | active->parent = parent; | ||
100 | return active->parent; | ||
97 | } | 101 | } |
98 | 102 | ||
99 | swayc_t *replace_child(swayc_t *child, swayc_t *new_child) { | 103 | swayc_t *replace_child(swayc_t *child, swayc_t *new_child) { |
@@ -102,8 +106,11 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) { | |||
102 | return NULL; | 106 | return NULL; |
103 | } | 107 | } |
104 | int i = index_child(child); | 108 | int i = index_child(child); |
105 | parent->children->items[i] = new_child; | 109 | if (child->is_floating) { |
106 | 110 | parent->floating->items[i] = new_child; | |
111 | } else { | ||
112 | parent->children->items[i] = new_child; | ||
113 | } | ||
107 | // Set parent and focus for new_child | 114 | // Set parent and focus for new_child |
108 | new_child->parent = child->parent; | 115 | new_child->parent = child->parent; |
109 | if (child->parent->focused == child) { | 116 | if (child->parent->focused == child) { |
@@ -167,7 +174,6 @@ swayc_t *remove_child(swayc_t *child) { | |||
167 | } | 174 | } |
168 | 175 | ||
169 | void swap_container(swayc_t *a, swayc_t *b) { | 176 | void swap_container(swayc_t *a, swayc_t *b) { |
170 | //TODO doesnt handle floating <-> tiling swap | ||
171 | if (!sway_assert(a&&b, "parameters must be non null") || | 177 | if (!sway_assert(a&&b, "parameters must be non null") || |
172 | !sway_assert(a->parent && b->parent, "containers must have parents")) { | 178 | !sway_assert(a->parent && b->parent, "containers must have parents")) { |
173 | return; | 179 | return; |
@@ -177,8 +183,16 @@ void swap_container(swayc_t *a, swayc_t *b) { | |||
177 | swayc_t *a_parent = a->parent; | 183 | swayc_t *a_parent = a->parent; |
178 | swayc_t *b_parent = b->parent; | 184 | swayc_t *b_parent = b->parent; |
179 | // Swap the pointers | 185 | // Swap the pointers |
180 | a_parent->children->items[a_index] = b; | 186 | if (a->is_floating) { |
181 | b_parent->children->items[b_index] = a; | 187 | a_parent->floating->items[a_index] = b; |
188 | } else { | ||
189 | a_parent->children->items[a_index] = b; | ||
190 | } | ||
191 | if (b->is_floating) { | ||
192 | b_parent->floating->items[b_index] = a; | ||
193 | } else { | ||
194 | b_parent->children->items[b_index] = a; | ||
195 | } | ||
182 | a->parent = b_parent; | 196 | a->parent = b_parent; |
183 | b->parent = a_parent; | 197 | b->parent = a_parent; |
184 | if (a_parent->focused == a) { | 198 | if (a_parent->focused == a) { |
@@ -560,7 +574,7 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio | |||
560 | 574 | ||
561 | if (can_move) { | 575 | if (can_move) { |
562 | int desired = index_child(container) + diff; | 576 | int desired = index_child(container) + diff; |
563 | if (desired < 0 || desired >= parent->children->length) { | 577 | if (container->is_floating || desired < 0 || desired >= parent->children->length) { |
564 | can_move = false; | 578 | can_move = false; |
565 | } else { | 579 | } else { |
566 | return parent->children->items[desired]; | 580 | return parent->children->items[desired]; |