aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-09-30 13:45:31 +0200
committerGitHub <noreply@github.com>2018-09-30 13:45:31 +0200
commite518c5dbaf93ab4f83031e83e03823d85469a30f (patch)
tree71b27108bc8f33ae6651fef489283fb015449d1e /sway
parent8f6aca2166030846655432d92498bb8d2e22036b (diff)
parent8f09ba78859ea894e843258246156406566d8e51 (diff)
Merge pull request #2728 from RedSoxFan/move-sticky-on-evac
Move sticky containers in output_evacuate
Diffstat (limited to 'sway')
-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) {
return;
}
struct sway_workspace *ws = con->workspace;
+ bool full = con->is_fullscreen;
+ if (full) {
+ container_set_fullscreen(con, false);
+ }
double new_lx = ws->x + (ws->width - con->width) / 2;
double new_ly = ws->y + (ws->height - con->height) / 2;
container_floating_translate(con, new_lx - con->x, new_ly - con->y);
+ if (full) {
+ container_set_fullscreen(con, true);
+ }
}
static 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) {
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);
+ 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) {
if (!output->workspaces->length) {
return;
@@ -130,17 +144,21 @@ static void output_evacuate(struct sway_output *output) {
workspace_detach(workspace);
- if (workspace_is_empty(workspace)) {
- workspace_begin_destroy(workspace);
- continue;
- }
-
struct sway_output *new_output =
workspace_output_get_highest_available(workspace, output);
if (!new_output) {
new_output = fallback_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);
+ }
+ workspace_begin_destroy(workspace);
+ continue;
+ }
+
if (new_output) {
workspace_output_add_priority(workspace, new_output);
output_add_workspace(new_output, workspace);