aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index c96b6a97..f99def6c 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -150,12 +150,43 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
150 150
151void view_init_floating(struct sway_view *view) { 151void view_init_floating(struct sway_view *view) {
152 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); 152 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
153 int max_width = ws->width * 0.6666; 153 int min_width, min_height;
154 int max_height = ws->height * 0.6666; 154 int max_width, max_height;
155 view->width = 155
156 view->natural_width > max_width ? max_width : view->natural_width; 156 if (config->floating_minimum_width == -1) { // no minimum
157 view->height = 157 min_width = 0;
158 view->natural_height > max_height ? max_height : view->natural_height; 158 } else if (config->floating_minimum_width == 0) { // automatic
159 min_width = 75;
160 } else {
161 min_width = config->floating_minimum_width;
162 }
163
164 if (config->floating_minimum_height == -1) { // no minimum
165 min_height = 0;
166 } else if (config->floating_minimum_height == 0) { // automatic
167 min_height = 50;
168 } else {
169 min_height = config->floating_minimum_height;
170 }
171
172 if (config->floating_maximum_width == -1) { // no maximum
173 max_width = INT_MAX;
174 } else if (config->floating_maximum_width == 0) { // automatic
175 max_width = ws->width * 0.6666;
176 } else {
177 max_width = config->floating_maximum_width;
178 }
179
180 if (config->floating_maximum_height == -1) { // no maximum
181 max_height = INT_MAX;
182 } else if (config->floating_maximum_height == 0) { // automatic
183 max_height = ws->height * 0.6666;
184 } else {
185 max_height = config->floating_maximum_height;
186 }
187
188 view->width = fmax(min_width, fmin(view->natural_width, max_width));
189 view->height = fmax(min_height, fmin(view->natural_height, max_height));
159 view->x = ws->x + (ws->width - view->width) / 2; 190 view->x = ws->x + (ws->width - view->width) / 2;
160 view->y = ws->y + (ws->height - view->height) / 2; 191 view->y = ws->y + (ws->height - view->height) / 2;
161 192