diff options
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 064d85f6..02b4d1b0 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -712,19 +712,28 @@ void container_floating_resize_and_center(struct sway_container *con) { | |||
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | static void container_floating_set_default_size(struct sway_container *con) { | 715 | void container_floating_set_default_size(struct sway_container *con) { |
716 | if (!sway_assert(con->workspace, "Expected a container on a workspace")) { | 716 | if (!sway_assert(con->workspace, "Expected a container on a workspace")) { |
717 | return; | 717 | return; |
718 | } | 718 | } |
719 | |||
719 | int min_width, max_width, min_height, max_height; | 720 | int min_width, max_width, min_height, max_height; |
720 | floating_calculate_constraints(&min_width, &max_width, | 721 | floating_calculate_constraints(&min_width, &max_width, |
721 | &min_height, &max_height); | 722 | &min_height, &max_height); |
722 | struct wlr_box *box = calloc(1, sizeof(struct wlr_box)); | 723 | struct wlr_box *box = calloc(1, sizeof(struct wlr_box)); |
723 | workspace_get_box(con->workspace, box); | 724 | workspace_get_box(con->workspace, box); |
725 | |||
726 | double width = fmax(min_width, fmin(box->width * 0.5, max_width)); | ||
727 | double height = fmax(min_height, fmin(box->height * 0.75, max_height)); | ||
724 | if (!con->view) { | 728 | if (!con->view) { |
725 | con->width = fmax(min_width, fmin(box->width * 0.5, max_width)); | 729 | con->width = width; |
726 | con->height = fmax(min_height, fmin(box->height * 0.75, max_height)); | 730 | con->height = height; |
731 | } else { | ||
732 | con->content_width = width; | ||
733 | con->content_height = height; | ||
734 | container_set_geometry_from_content(con); | ||
727 | } | 735 | } |
736 | |||
728 | free(box); | 737 | free(box); |
729 | } | 738 | } |
730 | 739 | ||