diff options
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r-- | sway/tree/output.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c index 06933dc4..c3176325 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -113,6 +113,20 @@ void output_enable(struct sway_output *output, struct output_config *oc) { | |||
113 | arrange_root(); | 113 | arrange_root(); |
114 | } | 114 | } |
115 | 115 | ||
116 | static void evacuate_sticky(struct sway_workspace *old_ws, | ||
117 | struct sway_output *new_output) { | ||
118 | struct sway_workspace *new_ws = output_get_active_workspace(new_output); | ||
119 | while (old_ws->floating->length) { | ||
120 | struct sway_container *sticky = old_ws->floating->items[0]; | ||
121 | container_detach(sticky); | ||
122 | workspace_add_floating(new_ws, sticky); | ||
123 | container_handle_fullscreen_reparent(sticky); | ||
124 | container_floating_move_to_center(sticky); | ||
125 | ipc_event_window(sticky, "move"); | ||
126 | } | ||
127 | workspace_detect_urgent(new_ws); | ||
128 | } | ||
129 | |||
116 | static void output_evacuate(struct sway_output *output) { | 130 | static void output_evacuate(struct sway_output *output) { |
117 | if (!output->workspaces->length) { | 131 | if (!output->workspaces->length) { |
118 | return; | 132 | return; |
@@ -130,17 +144,21 @@ static void output_evacuate(struct sway_output *output) { | |||
130 | 144 | ||
131 | workspace_detach(workspace); | 145 | workspace_detach(workspace); |
132 | 146 | ||
133 | if (workspace_is_empty(workspace)) { | ||
134 | workspace_begin_destroy(workspace); | ||
135 | continue; | ||
136 | } | ||
137 | |||
138 | struct sway_output *new_output = | 147 | struct sway_output *new_output = |
139 | workspace_output_get_highest_available(workspace, output); | 148 | workspace_output_get_highest_available(workspace, output); |
140 | if (!new_output) { | 149 | if (!new_output) { |
141 | new_output = fallback_output; | 150 | new_output = fallback_output; |
142 | } | 151 | } |
143 | 152 | ||
153 | if (workspace_is_empty(workspace)) { | ||
154 | // If floating is not empty, there are sticky containers to move | ||
155 | if (workspace->floating->length) { | ||
156 | evacuate_sticky(workspace, new_output); | ||
157 | } | ||
158 | workspace_begin_destroy(workspace); | ||
159 | continue; | ||
160 | } | ||
161 | |||
144 | if (new_output) { | 162 | if (new_output) { |
145 | workspace_output_add_priority(workspace, new_output); | 163 | workspace_output_add_priority(workspace, new_output); |
146 | output_add_workspace(new_output, workspace); | 164 | output_add_workspace(new_output, workspace); |