From 679c058fac986314675bacf7a7b01d263fb0db39 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Fri, 29 Mar 2019 12:26:08 -0400 Subject: scratchpad: set initial size This matches i3's behavior of setting scratchpad containers to 50% of the workspace's width and 75% of the workspace's height, bound by the minimum and maximum floating width/height. --- sway/tree/container.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'sway/tree/container.c') 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) { } } -static void container_floating_set_default_size(struct sway_container *con) { +void container_floating_set_default_size(struct sway_container *con) { if (!sway_assert(con->workspace, "Expected a container on a workspace")) { return; } + int min_width, max_width, min_height, max_height; floating_calculate_constraints(&min_width, &max_width, &min_height, &max_height); struct wlr_box *box = calloc(1, sizeof(struct wlr_box)); workspace_get_box(con->workspace, box); + + double width = fmax(min_width, fmin(box->width * 0.5, max_width)); + double height = fmax(min_height, fmin(box->height * 0.75, max_height)); if (!con->view) { - con->width = fmax(min_width, fmin(box->width * 0.5, max_width)); - con->height = fmax(min_height, fmin(box->height * 0.75, max_height)); + con->width = width; + con->height = height; + } else { + con->content_width = width; + con->content_height = height; + container_set_geometry_from_content(con); } + free(box); } -- cgit v1.2.3-54-g00ecf