aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/tree/container.c7
-rw-r--r--sway/tree/output.c28
2 files changed, 30 insertions, 5 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 66370a42..c30e7784 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -823,9 +823,16 @@ void container_floating_move_to_center(struct sway_container *con) {
823 return; 823 return;
824 } 824 }
825 struct sway_workspace *ws = con->workspace; 825 struct sway_workspace *ws = con->workspace;
826 bool full = con->is_fullscreen;
827 if (full) {
828 container_set_fullscreen(con, false);
829 }
826 double new_lx = ws->x + (ws->width - con->width) / 2; 830 double new_lx = ws->x + (ws->width - con->width) / 2;
827 double new_ly = ws->y + (ws->height - con->height) / 2; 831 double new_ly = ws->y + (ws->height - con->height) / 2;
828 container_floating_translate(con, new_lx - con->x, new_ly - con->y); 832 container_floating_translate(con, new_lx - con->x, new_ly - con->y);
833 if (full) {
834 container_set_fullscreen(con, true);
835 }
829} 836}
830 837
831static bool find_urgent_iterator(struct sway_container *con, void *data) { 838static bool find_urgent_iterator(struct sway_container *con, void *data) {
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
116static 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
116static void output_evacuate(struct sway_output *output) { 130static 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);