xdg_shell: add input validatoin for positioner anchor/gravity

This commit is contained in:
Dominique Martinet 2018-02-14 19:02:24 +01:00
parent 7d26a6debd
commit 1080bf69f8
1 changed files with 12 additions and 2 deletions

View File

@ -270,7 +270,12 @@ static void xdg_positioner_protocol_set_anchor(struct wl_client *client,
struct wlr_xdg_positioner *positioner =
wl_resource_get_user_data(resource);
/* post error if anchor > XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT ? */
if (anchor > XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT) {
wl_resource_post_error(resource,
XDG_POSITIONER_ERROR_INVALID_INPUT,
"invalid anchor value");
return;
}
positioner->anchor = anchor;
}
@ -280,7 +285,12 @@ static void xdg_positioner_protocol_set_gravity(struct wl_client *client,
struct wlr_xdg_positioner *positioner =
wl_resource_get_user_data(resource);
/* post error if gravity > XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT ? */
if (gravity > XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT) {
wl_resource_post_error(resource,
XDG_POSITIONER_ERROR_INVALID_INPUT,
"invalid gravity value");
return;
}
positioner->gravity = gravity;
}