diff options
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 8222a506..d2c4ffc4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -712,6 +712,21 @@ void floating_calculate_constraints(int *min_width, int *max_width, | |||
712 | 712 | ||
713 | } | 713 | } |
714 | 714 | ||
715 | void floating_fix_coordinates(struct sway_container *con, struct wlr_box *old, struct wlr_box *new) { | ||
716 | if (!old->width || !old->height) { | ||
717 | // Fall back to centering on the workspace. | ||
718 | container_floating_move_to_center(con); | ||
719 | } else { | ||
720 | int rel_x = con->pending.x - old->x + (con->pending.width / 2); | ||
721 | int rel_y = con->pending.y - old->y + (con->pending.height / 2); | ||
722 | |||
723 | con->pending.x = new->x + (double)(rel_x * new->width) / old->width - (con->pending.width / 2); | ||
724 | con->pending.y = new->y + (double)(rel_y * new->height) / old->height - (con->pending.height / 2); | ||
725 | |||
726 | sway_log(SWAY_DEBUG, "Transformed container %p to coords (%f, %f)", con, con->pending.x, con->pending.y); | ||
727 | } | ||
728 | } | ||
729 | |||
715 | static void floating_natural_resize(struct sway_container *con) { | 730 | static void floating_natural_resize(struct sway_container *con) { |
716 | int min_width, max_width, min_height, max_height; | 731 | int min_width, max_width, min_height, max_height; |
717 | floating_calculate_constraints(&min_width, &max_width, | 732 | floating_calculate_constraints(&min_width, &max_width, |
@@ -1025,6 +1040,13 @@ void container_floating_move_to(struct sway_container *con, | |||
1025 | workspace_add_floating(new_workspace, con); | 1040 | workspace_add_floating(new_workspace, con); |
1026 | arrange_workspace(old_workspace); | 1041 | arrange_workspace(old_workspace); |
1027 | arrange_workspace(new_workspace); | 1042 | arrange_workspace(new_workspace); |
1043 | // If the moved container was a visible scratchpad container, then | ||
1044 | // update its transform. | ||
1045 | if (con->scratchpad) { | ||
1046 | struct wlr_box output_box; | ||
1047 | output_get_box(new_output, &output_box); | ||
1048 | con->transform = output_box; | ||
1049 | } | ||
1028 | workspace_detect_urgent(old_workspace); | 1050 | workspace_detect_urgent(old_workspace); |
1029 | workspace_detect_urgent(new_workspace); | 1051 | workspace_detect_urgent(new_workspace); |
1030 | } | 1052 | } |