diff options
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 28cdc71e..20815654 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -142,6 +142,10 @@ struct sway_container *container_remove_child(struct sway_container *child) { | |||
142 | 142 | ||
143 | void container_move_to(struct sway_container *container, | 143 | void container_move_to(struct sway_container *container, |
144 | struct sway_container *destination) { | 144 | struct sway_container *destination) { |
145 | if (!sway_assert(container->type == C_CONTAINER || | ||
146 | container->type == C_VIEW, "Expected a container or view")) { | ||
147 | return; | ||
148 | } | ||
145 | if (container == destination | 149 | if (container == destination |
146 | || container_has_ancestor(container, destination)) { | 150 | || container_has_ancestor(container, destination)) { |
147 | return; | 151 | return; |
@@ -154,11 +158,8 @@ void container_move_to(struct sway_container *container, | |||
154 | container->width = container->height = 0; | 158 | container->width = container->height = 0; |
155 | container->saved_width = container->saved_height = 0; | 159 | container->saved_width = container->saved_height = 0; |
156 | 160 | ||
157 | struct sway_container *new_parent, *new_parent_focus; | 161 | struct sway_container *new_parent; |
158 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | ||
159 | 162 | ||
160 | // Get the focus of the destination before we change it. | ||
161 | new_parent_focus = seat_get_focus_inactive(seat, destination); | ||
162 | if (destination->type == C_VIEW) { | 163 | if (destination->type == C_VIEW) { |
163 | new_parent = container_add_sibling(destination, container); | 164 | new_parent = container_add_sibling(destination, container); |
164 | } else { | 165 | } else { |
@@ -167,24 +168,7 @@ void container_move_to(struct sway_container *container, | |||
167 | } | 168 | } |
168 | wl_signal_emit(&container->events.reparent, old_parent); | 169 | wl_signal_emit(&container->events.reparent, old_parent); |
169 | 170 | ||
170 | if (container->type == C_WORKSPACE) { | 171 | if (container->type == C_VIEW) { |
171 | // If moving a workspace to a new output, maybe create a new workspace | ||
172 | // on the previous output | ||
173 | if (old_parent->children->length == 0) { | ||
174 | char *ws_name = workspace_next_name(old_parent->name); | ||
175 | struct sway_container *ws = workspace_create(old_parent, ws_name); | ||
176 | free(ws_name); | ||
177 | seat_set_focus(seat, ws); | ||
178 | } | ||
179 | |||
180 | // Try to remove an empty workspace from the destination output. | ||
181 | container_reap_empty_recursive(new_parent_focus); | ||
182 | |||
183 | container_sort_workspaces(new_parent); | ||
184 | seat_set_focus(seat, new_parent); | ||
185 | workspace_output_raise_priority(container, old_parent, new_parent); | ||
186 | ipc_event_workspace(NULL, container, "move"); | ||
187 | } else if (container->type == C_VIEW) { | ||
188 | ipc_event_window(container, "move"); | 172 | ipc_event_window(container, "move"); |
189 | } | 173 | } |
190 | container_notify_subtree_changed(old_parent); | 174 | container_notify_subtree_changed(old_parent); |