diff options
author | Denis Doria <denisdoria@gmail.com> | 2016-05-31 14:59:33 +0200 |
---|---|---|
committer | Denis Doria <denisdoria@gmail.com> | 2016-05-31 14:59:33 +0200 |
commit | f1d5b89d3eabf0af267ed4a385079d616a82d2aa (patch) | |
tree | dc5017d0adbd1168c936d66faf34b82c2eb010b3 | |
parent | sway: fix IPC resource leak (diff) | |
download | sway-f1d5b89d3eabf0af267ed4a385079d616a82d2aa.tar.gz sway-f1d5b89d3eabf0af267ed4a385079d616a82d2aa.tar.zst sway-f1d5b89d3eabf0af267ed4a385079d616a82d2aa.zip |
Initial work for floating view with sane values
-rw-r--r-- | include/config.h | 6 | ||||
-rw-r--r-- | include/container.h | 2 | ||||
-rw-r--r-- | sway/config.c | 6 | ||||
-rw-r--r-- | sway/container.c | 25 | ||||
-rw-r--r-- | sway/handlers.c | 1 |
5 files changed, 40 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h index 3c1957b6..1a6ba19d 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -226,6 +226,12 @@ struct sway_config { | |||
226 | struct border_colors placeholder; | 226 | struct border_colors placeholder; |
227 | uint32_t background; | 227 | uint32_t background; |
228 | } border_colors; | 228 | } border_colors; |
229 | |||
230 | // floating view minimum | ||
231 | int32_t floating_maximum_width; | ||
232 | int32_t floating_maximum_height; | ||
233 | int32_t floating_minimum_width; | ||
234 | int32_t floating_minimum_height; | ||
229 | }; | 235 | }; |
230 | 236 | ||
231 | /** | 237 | /** |
diff --git a/include/container.h b/include/container.h index d1905720..50ca2bf5 100644 --- a/include/container.h +++ b/include/container.h | |||
@@ -168,6 +168,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle); | |||
168 | */ | 168 | */ |
169 | swayc_t *new_floating_view(wlc_handle handle); | 169 | swayc_t *new_floating_view(wlc_handle handle); |
170 | 170 | ||
171 | void floating_view_sane_size(swayc_t *view); | ||
172 | |||
171 | /** | 173 | /** |
172 | * Frees an output's container. | 174 | * Frees an output's container. |
173 | */ | 175 | */ |
diff --git a/sway/config.c b/sway/config.c index 14b657ef..95285eba 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -172,6 +172,12 @@ static void config_defaults(struct sway_config *config) { | |||
172 | config->font = strdup("monospace 10"); | 172 | config->font = strdup("monospace 10"); |
173 | config->font_height = get_font_text_height(config->font); | 173 | config->font_height = get_font_text_height(config->font); |
174 | 174 | ||
175 | // floating view | ||
176 | config->floating_maximum_width = -1; | ||
177 | config->floating_maximum_height = -1; | ||
178 | config->floating_minimum_width = 75; | ||
179 | config->floating_minimum_height = 50; | ||
180 | |||
175 | // Flags | 181 | // Flags |
176 | config->focus_follows_mouse = true; | 182 | config->focus_follows_mouse = true; |
177 | config->mouse_warping = true; | 183 | config->mouse_warping = true; |
diff --git a/sway/container.c b/sway/container.c index 4883a648..e00d2d7e 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -328,6 +328,31 @@ swayc_t *new_floating_view(wlc_handle handle) { | |||
328 | return view; | 328 | return view; |
329 | } | 329 | } |
330 | 330 | ||
331 | void floating_view_sane_size(swayc_t *view) { | ||
332 | if (config->floating_minimum_height != -1 && | ||
333 | view->desired_height < config->floating_minimum_height) { | ||
334 | view->desired_height = config->floating_minimum_height; | ||
335 | } | ||
336 | if (config->floating_minimum_width != -1 && | ||
337 | view->desired_width < config->floating_minimum_width) { | ||
338 | view->desired_width = config->floating_minimum_width; | ||
339 | } | ||
340 | |||
341 | if (config->floating_maximum_height != -1 && | ||
342 | view->desired_height > config->floating_maximum_height) { | ||
343 | view->desired_height = config->floating_maximum_height; | ||
344 | } | ||
345 | if (config->floating_maximum_width != -1 && | ||
346 | view->desired_width > config->floating_maximum_width) { | ||
347 | view->desired_width = config->floating_maximum_width; | ||
348 | } | ||
349 | sway_log(L_DEBUG, "Sane values for view to %d x %d @ %.f, %.f", | ||
350 | view->desired_width, view->desired_height, view->x, view->y); | ||
351 | |||
352 | return; | ||
353 | } | ||
354 | |||
355 | |||
331 | // Destroy container | 356 | // Destroy container |
332 | 357 | ||
333 | swayc_t *destroy_output(swayc_t *output) { | 358 | swayc_t *destroy_output(swayc_t *output) { |
diff --git a/sway/handlers.c b/sway/handlers.c index 931e1340..f8dd9f4d 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -350,6 +350,7 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo | |||
350 | view->desired_height = geometry->size.h; | 350 | view->desired_height = geometry->size.h; |
351 | 351 | ||
352 | if (view->is_floating) { | 352 | if (view->is_floating) { |
353 | floating_view_sane_size(view); | ||
353 | view->width = view->desired_width; | 354 | view->width = view->desired_width; |
354 | view->height = view->desired_height; | 355 | view->height = view->desired_height; |
355 | view->x = geometry->origin.x; | 356 | view->x = geometry->origin.x; |