diff options
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 2f4ae667..7bbeb4b1 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -142,11 +142,26 @@ struct sway_container *container_remove_child(struct sway_container *child) { | |||
142 | } | 142 | } |
143 | 143 | ||
144 | struct sway_container *parent = child->parent; | 144 | struct sway_container *parent = child->parent; |
145 | for (int i = 0; i < parent->children->length; ++i) { | 145 | if (!child->is_floating) { |
146 | if (parent->children->items[i] == child) { | 146 | for (int i = 0; i < parent->children->length; ++i) { |
147 | list_del(parent->children, i); | 147 | if (parent->children->items[i] == child) { |
148 | break; | 148 | list_del(parent->children, i); |
149 | break; | ||
150 | } | ||
151 | } | ||
152 | } else { | ||
153 | if (!sway_assert(parent->type == C_WORKSPACE && child->type == C_VIEW, | ||
154 | "Found floating non-view and/or in non-workspace")) { | ||
155 | return parent; | ||
156 | } | ||
157 | struct sway_workspace *ws = parent->sway_workspace; | ||
158 | for (int i = 0; i < ws->floating->length; ++i) { | ||
159 | if (ws->floating->items[i] == child) { | ||
160 | list_del(ws->floating, i); | ||
161 | break; | ||
162 | } | ||
149 | } | 163 | } |
164 | child->is_floating = false; | ||
150 | } | 165 | } |
151 | child->parent = NULL; | 166 | child->parent = NULL; |
152 | container_notify_subtree_changed(parent); | 167 | container_notify_subtree_changed(parent); |
@@ -154,6 +169,26 @@ struct sway_container *container_remove_child(struct sway_container *child) { | |||
154 | return parent; | 169 | return parent; |
155 | } | 170 | } |
156 | 171 | ||
172 | void container_add_floating(struct sway_container *workspace, | ||
173 | struct sway_container *child) { | ||
174 | if (!sway_assert(workspace->type == C_WORKSPACE && child->type == C_VIEW, | ||
175 | "Attempted to float non-view and/or in non-workspace")) { | ||
176 | return; | ||
177 | } | ||
178 | if (!sway_assert(!child->parent, | ||
179 | "child already has a parent (invalid call)")) { | ||
180 | return; | ||
181 | } | ||
182 | if (!sway_assert(!child->is_floating, | ||
183 | "child is already floating (invalid state)")) { | ||
184 | return; | ||
185 | } | ||
186 | struct sway_workspace *ws = workspace->sway_workspace; | ||
187 | list_add(ws->floating, child); | ||
188 | child->parent = workspace; | ||
189 | child->is_floating = true; | ||
190 | } | ||
191 | |||
157 | void container_move_to(struct sway_container *container, | 192 | void container_move_to(struct sway_container *container, |
158 | struct sway_container *destination) { | 193 | struct sway_container *destination) { |
159 | if (container == destination | 194 | if (container == destination |