aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-03-29 12:26:08 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-03-31 17:49:05 -0600
commit679c058fac986314675bacf7a7b01d263fb0db39 (patch)
tree1d5ade6a8e4304f18fe6ac5943e3ac6aa68f4136 /sway/tree/container.c
parentfloating: fix size of non-view containers (diff)
downloadsway-679c058fac986314675bacf7a7b01d263fb0db39.tar.gz
sway-679c058fac986314675bacf7a7b01d263fb0db39.tar.zst
sway-679c058fac986314675bacf7a7b01d263fb0db39.zip
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.
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c15
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
715static void container_floating_set_default_size(struct sway_container *con) { 715void 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