aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authormwenzkowski <29407878+mwenzkowski@users.noreply.github.com>2020-10-28 13:50:24 +0100
committerTudor Brindus <me@tbrindus.ca>2020-10-28 09:45:12 -0400
commit4799cb09606ba8b3cc3969c24637b3c6c9eac485 (patch)
tree35931999e8e09e0acb0d6589a56d7b291759394b /sway
parent39328ca4e4b97bd76153869f6a0a20fef3c17112 (diff)
downloadsway-4799cb09606ba8b3cc3969c24637b3c6c9eac485.tar.xz
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')
-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) {
arrange_root();
}
-static void evacuate_sticky(struct sway_container *con, void *data) {
- if (container_is_floating(con) && con->is_sticky) {
- struct sway_workspace *new_ws = data;
- if (!sway_assert(new_ws, "Expected workspace to not be null")) {
- return;
- }
- container_detach(con);
- workspace_add_floating(new_ws, con);
- container_handle_fullscreen_reparent(con);
- container_floating_move_to_center(con);
- ipc_event_window(con, "move");
+static void evacuate_sticky(struct sway_workspace *old_ws,
+ struct sway_output *new_output) {
+ struct sway_workspace *new_ws = output_get_active_workspace(new_output);
+ if (!sway_assert(new_ws, "New output does not have a workspace")) {
+ return;
+ }
+ while(old_ws->floating->length) {
+ struct sway_container *sticky = old_ws->floating->items[0];
+ container_detach(sticky);
+ workspace_add_floating(new_ws, sticky);
+ container_handle_fullscreen_reparent(sticky);
+ container_floating_move_to_center(sticky);
+ ipc_event_window(sticky, "move");
}
+ workspace_detect_urgent(new_ws);
}
static void output_evacuate(struct sway_output *output) {
@@ -198,10 +201,9 @@ static void output_evacuate(struct sway_output *output) {
if (workspace_is_empty(workspace)) {
// If the new output has an active workspace (the noop output may
// not have one), move all sticky containers to it
- if (new_output_ws) {
- workspace_for_each_container(workspace, evacuate_sticky,
- new_output_ws);
- workspace_detect_urgent(new_output_ws);
+ if (new_output_ws &&
+ workspace_num_sticky_containers(workspace) > 0) {
+ evacuate_sticky(workspace, new_output);
}
if (workspace_num_sticky_containers(workspace) == 0) {