diff options
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 20815654..38e14d00 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -150,22 +150,44 @@ void container_move_to(struct sway_container *container, | |||
150 | || container_has_ancestor(container, destination)) { | 150 | || container_has_ancestor(container, destination)) { |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | struct sway_container *old_parent = NULL; | ||
154 | struct sway_container *new_parent = NULL; | ||
153 | if (container_is_floating(container)) { | 155 | if (container_is_floating(container)) { |
154 | // TODO | 156 | // Resolve destination into a workspace |
155 | return; | 157 | struct sway_container *new_ws = NULL; |
156 | } | 158 | if (destination->type == C_OUTPUT) { |
157 | struct sway_container *old_parent = container_remove_child(container); | 159 | new_ws = output_get_active_workspace(destination->sway_output); |
158 | container->width = container->height = 0; | 160 | } else if (destination->type == C_WORKSPACE) { |
159 | container->saved_width = container->saved_height = 0; | 161 | new_ws = destination; |
160 | 162 | } else { | |
161 | struct sway_container *new_parent; | 163 | new_ws = container_parent(destination, C_WORKSPACE); |
162 | 164 | } | |
163 | if (destination->type == C_VIEW) { | 165 | if (!new_ws) { |
164 | new_parent = container_add_sibling(destination, container); | 166 | // This can happen if the user has run "move container to mark foo", |
167 | // where mark foo is on a hidden scratchpad container. | ||
168 | return; | ||
169 | } | ||
170 | struct sway_container *old_output = | ||
171 | container_parent(container, C_OUTPUT); | ||
172 | old_parent = container_remove_child(container); | ||
173 | container_add_child(new_ws->sway_workspace->floating, container); | ||
174 | // If changing output, center it within the workspace | ||
175 | if (old_output != new_ws->parent && !container->is_fullscreen) { | ||
176 | container_floating_move_to_center(container); | ||
177 | } | ||
165 | } else { | 178 | } else { |
166 | new_parent = destination; | 179 | old_parent = container_remove_child(container); |
167 | container_add_child(destination, container); | 180 | container->width = container->height = 0; |
181 | container->saved_width = container->saved_height = 0; | ||
182 | |||
183 | if (destination->type == C_VIEW) { | ||
184 | new_parent = container_add_sibling(destination, container); | ||
185 | } else { | ||
186 | new_parent = destination; | ||
187 | container_add_child(destination, container); | ||
188 | } | ||
168 | } | 189 | } |
190 | |||
169 | wl_signal_emit(&container->events.reparent, old_parent); | 191 | wl_signal_emit(&container->events.reparent, old_parent); |
170 | 192 | ||
171 | if (container->type == C_VIEW) { | 193 | if (container->type == C_VIEW) { |