Initial work for floating view with sane values

This commit is contained in:
Denis Doria 2016-05-31 14:59:33 +02:00
parent 9d7d73df7f
commit f1d5b89d3e
5 changed files with 40 additions and 0 deletions

View file

@ -226,6 +226,12 @@ struct sway_config {
struct border_colors placeholder; struct border_colors placeholder;
uint32_t background; uint32_t background;
} border_colors; } 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;
}; };
/** /**

View file

@ -168,6 +168,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
*/ */
swayc_t *new_floating_view(wlc_handle handle); swayc_t *new_floating_view(wlc_handle handle);
void floating_view_sane_size(swayc_t *view);
/** /**
* Frees an output's container. * Frees an output's container.
*/ */

View file

@ -172,6 +172,12 @@ static void config_defaults(struct sway_config *config) {
config->font = strdup("monospace 10"); config->font = strdup("monospace 10");
config->font_height = get_font_text_height(config->font); 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 // Flags
config->focus_follows_mouse = true; config->focus_follows_mouse = true;
config->mouse_warping = true; config->mouse_warping = true;

View file

@ -328,6 +328,31 @@ swayc_t *new_floating_view(wlc_handle handle) {
return view; 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 // Destroy container
swayc_t *destroy_output(swayc_t *output) { swayc_t *destroy_output(swayc_t *output) {

View file

@ -350,6 +350,7 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo
view->desired_height = geometry->size.h; view->desired_height = geometry->size.h;
if (view->is_floating) { if (view->is_floating) {
floating_view_sane_size(view);
view->width = view->desired_width; view->width = view->desired_width;
view->height = view->desired_height; view->height = view->desired_height;
view->x = geometry->origin.x; view->x = geometry->origin.x;