xdg-shell: send invalid_size errors

This commit is contained in:
Kirill Primak 2022-11-04 21:56:11 +03:00 committed by Simon Ser
parent 6c3d6be74b
commit c2fb5289c2
3 changed files with 20 additions and 6 deletions

View File

@ -1,5 +1,5 @@
wayland_protos = dependency('wayland-protocols',
version: '>=1.27',
version: '>=1.28',
fallback: 'wayland-protocols',
default_options: ['tests=false'],
)

View File

@ -216,9 +216,9 @@ static void xdg_surface_handle_set_window_geometry(struct wl_client *client,
}
if (width <= 0 || height <= 0) {
wlr_log(WLR_ERROR, "Client tried to set invalid geometry");
//XXX: Switch to the proper error value once available
wl_resource_post_error(resource, -1, "Tried to set invalid xdg-surface geometry");
wl_resource_post_error(resource,
XDG_SURFACE_ERROR_INVALID_SIZE,
"Tried to set invalid xdg-surface geometry");
return;
}

View File

@ -116,6 +116,22 @@ struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
}
void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel) {
struct wlr_xdg_toplevel_state *pending = &toplevel->pending;
// 1) Negative values are prohibited
// 2) If both min and max are set (aren't 0), min ≤ max
if (pending->min_width < 0 || pending->min_height < 0 ||
pending->max_width < 0 || pending->max_height < 0 ||
(pending->max_width != 0 && pending->max_width < pending->min_width) ||
(pending->max_height != 0 && pending->max_height < pending->min_height)) {
wl_resource_post_error(toplevel->resource,
XDG_TOPLEVEL_ERROR_INVALID_SIZE,
"client provided an invalid min or max size");
return;
}
toplevel->current = toplevel->pending;
if (!toplevel->added) {
// on the first commit, send a configure request to tell the client it
// is added
@ -133,8 +149,6 @@ void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel) {
}
return;
}
toplevel->current = toplevel->pending;
}
static const struct xdg_toplevel_interface xdg_toplevel_implementation;