summaryrefslogtreecommitdiff
path: root/sway/tree/output.c
diff options
context:
space:
mode:
authormwenzkowski <[email protected]>2020-10-28 00:02:08 +0100
committerTudor Brindus <[email protected]>2020-10-27 19:26:26 -0400
commit32788a93f23eaa683f7a88694c778cd084607754 (patch)
treedf3ecb3274ccc953c28445e483b24ca22cec9c10 /sway/tree/output.c
parent0cb9282aeebddeed0b5259f153f98a45311053a5 (diff)
output: evacuate sticky containers only if new output has a workspace
Sticky floating containers on an otherwise empty workspace can only be evacuated if the new output has an active workspace. The noop output may not have one and in that case we have to move the whole workspace to the new output.
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r--sway/tree/output.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c
index d600c5c3..4dc22755 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -152,21 +152,18 @@ void output_enable(struct sway_output *output) {
arrange_root();
}
-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");
+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");
}
- workspace_detect_urgent(new_ws);
}
static void output_evacuate(struct sway_output *output) {
@@ -195,17 +192,23 @@ static void output_evacuate(struct sway_output *output) {
new_output = root->noop_output;
}
+ struct sway_workspace *new_output_ws =
+ output_get_active_workspace(new_output);
+
if (workspace_is_empty(workspace)) {
- // If floating is not empty, there are sticky containers to move
- if (workspace->floating->length) {
- evacuate_sticky(workspace, new_output);
+ // 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);
}
- workspace_begin_destroy(workspace);
- continue;
- }
- struct sway_workspace *new_output_ws =
- output_get_active_workspace(new_output);
+ if (workspace_num_sticky_containers(workspace) == 0) {
+ workspace_begin_destroy(workspace);
+ continue;
+ }
+ }
workspace_output_add_priority(workspace, new_output);
output_add_workspace(new_output, workspace);