aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-07 09:30:27 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-08 08:48:20 +1000
commita0649190deaaf093112e99881c25ff550f07e96b (patch)
tree922fc56dad707ceeebaf6ea3364751e51d764407 /sway/tree/layout.c
parentImplement move to workspace on a floating container (diff)
downloadsway-a0649190deaaf093112e99881c25ff550f07e96b.tar.gz
sway-a0649190deaaf093112e99881c25ff550f07e96b.tar.zst
sway-a0649190deaaf093112e99881c25ff550f07e96b.zip
Fix edge cases when moving floating container to new workspace
* Removes container_floating_move_to_container, instead opting to put that logic in container_move_to * In the seat code, focusing a floating view now updates the pending state only and lets the next transaction carry it over to the current state. This is required, otherwise it would crash. * When unfullscreening a floating container, an output check is now done to see if it should center it.
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index bdcd1a9b..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 container_floating_move_to_container(container, destination); 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) {