diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-05-31 10:29:44 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-05-31 10:29:44 -0400 |
commit | df8caa29a71f041a8e94ff410274a598abfe9a81 (patch) | |
tree | 9665fbaac9e2f7d099d7c54715404032ea406551 | |
parent | 7f6b3d1c1f0727c8db623c18cc8a4fd948be995d (diff) | |
parent | 3c4c62301290991b790b90c840d18b398e0522c8 (diff) |
Merge pull request #685 from thuck/floating_size
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 { struct border_colors placeholder; uint32_t background; } border_colors; + + // floating view minimum + int32_t floating_maximum_width; + int32_t floating_maximum_height; + int32_t floating_minimum_width; + int32_t floating_minimum_height; }; /** 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); */ swayc_t *new_floating_view(wlc_handle handle); +void floating_view_sane_size(swayc_t *view); + /** * Frees an output's container. */ 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) { config->font = strdup("monospace 10"); config->font_height = get_font_text_height(config->font); + // floating view + config->floating_maximum_width = -1; + config->floating_maximum_height = -1; + config->floating_minimum_width = 75; + config->floating_minimum_height = 50; + // Flags config->focus_follows_mouse = true; 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) { return view; } +void floating_view_sane_size(swayc_t *view) { + if (config->floating_minimum_height != -1 && + view->desired_height < config->floating_minimum_height) { + view->desired_height = config->floating_minimum_height; + } + if (config->floating_minimum_width != -1 && + view->desired_width < config->floating_minimum_width) { + view->desired_width = config->floating_minimum_width; + } + + if (config->floating_maximum_height != -1 && + view->desired_height > config->floating_maximum_height) { + view->desired_height = config->floating_maximum_height; + } + if (config->floating_maximum_width != -1 && + view->desired_width > config->floating_maximum_width) { + view->desired_width = config->floating_maximum_width; + } + sway_log(L_DEBUG, "Sane values for view to %d x %d @ %.f, %.f", + view->desired_width, view->desired_height, view->x, view->y); + + return; +} + + // Destroy container 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 view->desired_height = geometry->size.h; if (view->is_floating) { + floating_view_sane_size(view); view->width = view->desired_width; view->height = view->desired_height; view->x = geometry->origin.x; |