Consider view's min/max sizes when resizing

This commit is contained in:
Ryan Dwyer 2018-07-21 12:13:00 +10:00
parent 9df660ee31
commit 011d1ebfa4
5 changed files with 52 additions and 1 deletions

View file

@ -243,7 +243,7 @@ static void handle_resize_motion(struct sway_seat *seat,
grow_height = seat->op_ref_height * max_multiplier;
}
// Determine new width/height, and accommodate for min/max values
// Determine new width/height, and accommodate for floating min/max values
double width = seat->op_ref_width + grow_width;
double height = seat->op_ref_height + grow_height;
int min_width, max_width, min_height, max_height;
@ -252,6 +252,15 @@ static void handle_resize_motion(struct sway_seat *seat,
width = fmax(min_width, fmin(width, max_width));
height = fmax(min_height, fmin(height, max_height));
// Apply the view's min/max size
if (con->type == C_VIEW) {
double view_min_width, view_max_width, view_min_height, view_max_height;
view_get_constraints(con->sway_view, &view_min_width, &view_max_width,
&view_min_height, &view_max_height);
width = fmax(view_min_width, fmin(width, view_max_width));
height = fmax(view_min_height, fmin(height, view_max_height));
}
// Recalculate these, in case we hit a min/max limit
grow_width = width - seat->op_ref_width;
grow_height = height - seat->op_ref_height;