aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/tree/container.c15
-rw-r--r--sway/tree/root.c2
2 files changed, 14 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) {
}
}
-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);
}
diff --git a/sway/tree/root.c b/sway/tree/root.c
index bc9c610d..3d93405e 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -62,6 +62,8 @@ void root_scratchpad_add_container(struct sway_container *con) {
struct sway_container *parent = con->parent;
struct sway_workspace *workspace = con->workspace;
container_set_floating(con, true);
+ container_floating_set_default_size(con);
+ container_floating_move_to_center(con);
container_detach(con);
con->scratchpad = true;
list_add(root->scratchpad, con);