diff options
-rw-r--r-- | include/sway/tree/workspace.h | 2 | ||||
-rw-r--r-- | sway/tree/output.c | 47 | ||||
-rw-r--r-- | sway/tree/workspace.c | 13 |
3 files changed, 40 insertions, 22 deletions
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 1adbe68a..fe200ec0 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h | |||
@@ -132,4 +132,6 @@ void workspace_get_box(struct sway_workspace *workspace, struct wlr_box *box); | |||
132 | 132 | ||
133 | size_t workspace_num_tiling_views(struct sway_workspace *ws); | 133 | size_t workspace_num_tiling_views(struct sway_workspace *ws); |
134 | 134 | ||
135 | size_t workspace_num_sticky_containers(struct sway_workspace *ws); | ||
136 | |||
135 | #endif | 137 | #endif |
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) { | |||
152 | arrange_root(); | 152 | arrange_root(); |
153 | } | 153 | } |
154 | 154 | ||
155 | static void evacuate_sticky(struct sway_workspace *old_ws, | 155 | static void evacuate_sticky(struct sway_container *con, void *data) { |
156 | struct sway_output *new_output) { | 156 | if (container_is_floating(con) && con->is_sticky) { |
157 | struct sway_workspace *new_ws = output_get_active_workspace(new_output); | 157 | struct sway_workspace *new_ws = data; |
158 | if (!sway_assert(new_ws, "New output does not have a workspace")) { | 158 | if (!sway_assert(new_ws, "Expected workspace to not be null")) { |
159 | return; | 159 | return; |
160 | } | 160 | } |
161 | while (old_ws->floating->length) { | 161 | container_detach(con); |
162 | struct sway_container *sticky = old_ws->floating->items[0]; | 162 | workspace_add_floating(new_ws, con); |
163 | container_detach(sticky); | 163 | container_handle_fullscreen_reparent(con); |
164 | workspace_add_floating(new_ws, sticky); | 164 | container_floating_move_to_center(con); |
165 | container_handle_fullscreen_reparent(sticky); | 165 | ipc_event_window(con, "move"); |
166 | container_floating_move_to_center(sticky); | ||
167 | ipc_event_window(sticky, "move"); | ||
168 | } | 166 | } |
169 | workspace_detect_urgent(new_ws); | ||
170 | } | 167 | } |
171 | 168 | ||
172 | static void output_evacuate(struct sway_output *output) { | 169 | static void output_evacuate(struct sway_output *output) { |
@@ -195,17 +192,23 @@ static void output_evacuate(struct sway_output *output) { | |||
195 | new_output = root->noop_output; | 192 | new_output = root->noop_output; |
196 | } | 193 | } |
197 | 194 | ||
195 | struct sway_workspace *new_output_ws = | ||
196 | output_get_active_workspace(new_output); | ||
197 | |||
198 | if (workspace_is_empty(workspace)) { | 198 | if (workspace_is_empty(workspace)) { |
199 | // If floating is not empty, there are sticky containers to move | 199 | // If the new output has an active workspace (the noop output may |
200 | if (workspace->floating->length) { | 200 | // not have one), move all sticky containers to it |
201 | evacuate_sticky(workspace, new_output); | 201 | if (new_output_ws) { |
202 | workspace_for_each_container(workspace, evacuate_sticky, | ||
203 | new_output_ws); | ||
204 | workspace_detect_urgent(new_output_ws); | ||
202 | } | 205 | } |
203 | workspace_begin_destroy(workspace); | ||
204 | continue; | ||
205 | } | ||
206 | 206 | ||
207 | struct sway_workspace *new_output_ws = | 207 | if (workspace_num_sticky_containers(workspace) == 0) { |
208 | output_get_active_workspace(new_output); | 208 | workspace_begin_destroy(workspace); |
209 | continue; | ||
210 | } | ||
211 | } | ||
209 | 212 | ||
210 | workspace_output_add_priority(workspace, new_output); | 213 | workspace_output_add_priority(workspace, new_output); |
211 | output_add_workspace(new_output, workspace); | 214 | output_add_workspace(new_output, workspace); |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 3bcba8e5..476c2568 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -817,3 +817,16 @@ size_t workspace_num_tiling_views(struct sway_workspace *ws) { | |||
817 | workspace_for_each_container(ws, count_tiling_views, &count); | 817 | workspace_for_each_container(ws, count_tiling_views, &count); |
818 | return count; | 818 | return count; |
819 | } | 819 | } |
820 | |||
821 | static void count_sticky_containers(struct sway_container *con, void *data) { | ||
822 | if (container_is_floating(con) && con->is_sticky) { | ||
823 | size_t *count = data; | ||
824 | *count += 1; | ||
825 | } | ||
826 | } | ||
827 | |||
828 | size_t workspace_num_sticky_containers(struct sway_workspace *ws) { | ||
829 | size_t count = 0; | ||
830 | workspace_for_each_container(ws, count_sticky_containers, &count); | ||
831 | return count; | ||
832 | } | ||