Merge pull request #349 from emersion/resize-bounds

Enforce resize bounds in rootston
This commit is contained in:
Drew DeVault 2017-10-28 09:23:25 -04:00 committed by GitHub
commit b3d5f1146c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

View file

@ -160,6 +160,13 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
width += dx; width += dx;
} }
if (width < 0) {
width = 0;
}
if (height < 0) {
height = 0;
}
// TODO we might need one configure event for this // TODO we might need one configure event for this
if (active_x != input->active_view->x || if (active_x != input->active_view->x ||
active_y != input->active_view->y) { active_y != input->active_view->y) {

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); assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { 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); wlr_xdg_toplevel_v6_set_size(surf, width, height);
} }
} }

View file

@ -22,6 +22,24 @@ static void activate(struct roots_view *view, bool active) {
static void resize(struct roots_view *view, uint32_t width, uint32_t height) { static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
assert(view->type == ROOTS_XWAYLAND_VIEW); assert(view->type == ROOTS_XWAYLAND_VIEW);
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
struct wlr_xwayland_surface_size_hints *size_hints =
xwayland_surface->size_hints;
if (size_hints != NULL) {
if (width < (uint32_t)size_hints->min_width) {
width = size_hints->min_width;
} else if (size_hints->max_width > 0 &&
width > (uint32_t)size_hints->max_width) {
width = size_hints->max_width;
}
if (height < (uint32_t)size_hints->min_height) {
height = size_hints->min_height;
} else if (size_hints->max_height > 0 &&
height > (uint32_t)size_hints->max_height) {
height = size_hints->max_height;
}
}
wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
xwayland_surface->x, xwayland_surface->y, width, height); xwayland_surface->x, xwayland_surface->y, width, height);
} }