aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/tree/container.c15
-rw-r--r--sway/tree/output.c21
2 files changed, 32 insertions, 4 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 93cff7ff..f84ce360 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -651,6 +651,17 @@ void floating_calculate_constraints(int *min_width, int *max_width,
651 651
652void container_init_floating(struct sway_container *con) { 652void container_init_floating(struct sway_container *con) {
653 struct sway_workspace *ws = con->workspace; 653 struct sway_workspace *ws = con->workspace;
654 struct wlr_box *ob = wlr_output_layout_get_box(root->output_layout,
655 ws->output->wlr_output);
656 if (!ob) {
657 // On NOOP output. Will be called again when moved to an output
658 con->x = 0;
659 con->y = 0;
660 con->width = 0;
661 con->height = 0;
662 return;
663 }
664
654 int min_width, max_width, min_height, max_height; 665 int min_width, max_width, min_height, max_height;
655 floating_calculate_constraints(&min_width, &max_width, 666 floating_calculate_constraints(&min_width, &max_width,
656 &min_height, &max_height); 667 &min_height, &max_height);
@@ -659,8 +670,6 @@ void container_init_floating(struct sway_container *con) {
659 con->width = max_width; 670 con->width = max_width;
660 con->height = max_height; 671 con->height = max_height;
661 if (con->width > ws->width || con->height > ws->height) { 672 if (con->width > ws->width || con->height > ws->height) {
662 struct wlr_box *ob = wlr_output_layout_get_box(root->output_layout,
663 ws->output->wlr_output);
664 con->x = ob->x + (ob->width - con->width) / 2; 673 con->x = ob->x + (ob->width - con->width) / 2;
665 con->y = ob->y + (ob->height - con->height) / 2; 674 con->y = ob->y + (ob->height - con->height) / 2;
666 } else { 675 } else {
@@ -675,8 +684,6 @@ void container_init_floating(struct sway_container *con) {
675 fmax(min_height, fmin(view->natural_height, max_height)); 684 fmax(min_height, fmin(view->natural_height, max_height));
676 if (con->content_width > ws->width 685 if (con->content_width > ws->width
677 || con->content_height > ws->height) { 686 || con->content_height > ws->height) {
678 struct wlr_box *ob = wlr_output_layout_get_box(root->output_layout,
679 ws->output->wlr_output);
680 con->content_x = ob->x + (ob->width - con->content_width) / 2; 687 con->content_x = ob->x + (ob->width - con->content_width) / 2;
681 con->content_y = ob->y + (ob->height - con->content_height) / 2; 688 con->content_y = ob->y + (ob->height - con->content_height) / 2;
682 } else { 689 } else {
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 1202ba3c..7867c6bc 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -60,6 +60,27 @@ static void restore_workspaces(struct sway_output *output) {
60 struct sway_workspace *ws = root->noop_output->workspaces->items[0]; 60 struct sway_workspace *ws = root->noop_output->workspaces->items[0];
61 workspace_detach(ws); 61 workspace_detach(ws);
62 output_add_workspace(output, ws); 62 output_add_workspace(output, ws);
63
64 // If the floater was made floating while on the NOOP output, its width
65 // and height will be zero and it should be reinitialized as a floating
66 // container to get the appropriate size and location. Additionally, if
67 // the floater is wider or taller than the output or is completely
68 // outside of the output's bounds, do the same as the output layout has
69 // likely changed and the maximum size needs to be checked and the
70 // floater re-centered
71 for (int i = 0; i < ws->floating->length; i++) {
72 struct sway_container *floater = ws->floating->items[i];
73 if (floater->width == 0 || floater->height == 0 ||
74 floater->width > output->width ||
75 floater->height > output->height ||
76 floater->x > output->lx + output->width ||
77 floater->y > output->ly + output->height ||
78 floater->x + floater->width < output->lx ||
79 floater->y + floater->height < output->ly) {
80 container_init_floating(floater);
81 }
82 }
83
63 ipc_event_workspace(NULL, ws, "move"); 84 ipc_event_workspace(NULL, ws, "move");
64 } 85 }
65 86