Enforce resize bounds in rootston

This commit is contained in:
emersion 2017-10-28 11:58:34 +02:00
parent b97160238f
commit fb0c9a356e
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 40 additions and 0 deletions

View file

@ -29,6 +29,21 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
struct wlr_xdg_toplevel_v6_state *state =
&surf->toplevel_state->current;
if (width < state->min_width) {
width = state->min_width;
} else if (state->max_width > 0 &&
width < state->max_width) {
width = state->max_width;
}
if (height < state->min_height) {
height = state->min_height;
} else if (state->max_height > 0 &&
height < state->max_height) {
height = state->max_height;
}
wlr_xdg_toplevel_v6_set_size(surf, width, height);
}
}