aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree
diff options
context:
space:
mode:
authorLibravatar mwenzkowski <29407878+mwenzkowski@users.noreply.github.com>2020-10-28 13:50:24 +0100
committerLibravatar Tudor Brindus <me@tbrindus.ca>2020-10-28 09:45:12 -0400
commit4799cb09606ba8b3cc3969c24637b3c6c9eac485 (patch)
tree35931999e8e09e0acb0d6589a56d7b291759394b /sway/tree
parentIn container_split, set a floating container's view to tiled (diff)
downloadsway-4799cb09606ba8b3cc3969c24637b3c6c9eac485.tar.gz
sway-4799cb09606ba8b3cc3969c24637b3c6c9eac485.tar.zst
sway-4799cb09606ba8b3cc3969c24637b3c6c9eac485.zip
output: Revert implementation of evacuate_sticky()
The function evacuate_sticky() was changed in commit 32788a93 to be used by workspace_for_each_container() to make the code more readable. But I overlooked that it is not safe to use workspace_for_each_container() to remove container from a workspace. This commit restores the previous implementation for evacuate_sticky().
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/output.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 4dc22755..f15a84b3 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -152,18 +152,21 @@ void output_enable(struct sway_output *output) {
152 arrange_root(); 152 arrange_root();
153} 153}
154 154
155static void evacuate_sticky(struct sway_container *con, void *data) { 155static void evacuate_sticky(struct sway_workspace *old_ws,
156 if (container_is_floating(con) && con->is_sticky) { 156 struct sway_output *new_output) {
157 struct sway_workspace *new_ws = data; 157 struct sway_workspace *new_ws = output_get_active_workspace(new_output);
158 if (!sway_assert(new_ws, "Expected workspace to not be null")) { 158 if (!sway_assert(new_ws, "New output does not have a workspace")) {
159 return; 159 return;
160 } 160 }
161 container_detach(con); 161 while(old_ws->floating->length) {
162 workspace_add_floating(new_ws, con); 162 struct sway_container *sticky = old_ws->floating->items[0];
163 container_handle_fullscreen_reparent(con); 163 container_detach(sticky);
164 container_floating_move_to_center(con); 164 workspace_add_floating(new_ws, sticky);
165 ipc_event_window(con, "move"); 165 container_handle_fullscreen_reparent(sticky);
166 container_floating_move_to_center(sticky);
167 ipc_event_window(sticky, "move");
166 } 168 }
169 workspace_detect_urgent(new_ws);
167} 170}
168 171
169static void output_evacuate(struct sway_output *output) { 172static void output_evacuate(struct sway_output *output) {
@@ -198,10 +201,9 @@ static void output_evacuate(struct sway_output *output) {
198 if (workspace_is_empty(workspace)) { 201 if (workspace_is_empty(workspace)) {
199 // If the new output has an active workspace (the noop output may 202 // If the new output has an active workspace (the noop output may
200 // not have one), move all sticky containers to it 203 // not have one), move all sticky containers to it
201 if (new_output_ws) { 204 if (new_output_ws &&
202 workspace_for_each_container(workspace, evacuate_sticky, 205 workspace_num_sticky_containers(workspace) > 0) {
203 new_output_ws); 206 evacuate_sticky(workspace, new_output);
204 workspace_detect_urgent(new_output_ws);
205 } 207 }
206 208
207 if (workspace_num_sticky_containers(workspace) == 0) { 209 if (workspace_num_sticky_containers(workspace) == 0) {