diff options
author | Kirill Primak <vyivel@eclair.cafe> | 2022-11-04 21:56:11 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-11-17 10:03:52 +0000 |
commit | c2fb5289c2909be10ce11ce9c0bcf58d110d1cdf (patch) | |
tree | d2549ef4c68365d327f8ee1b2ef38e3892db466b | |
parent | 6c3d6be74b75e9aa8b1d5b454eb3b408bfdcfe30 (diff) |
xdg-shell: send invalid_size errors
-rw-r--r-- | protocol/meson.build | 2 | ||||
-rw-r--r-- | types/xdg_shell/wlr_xdg_surface.c | 6 | ||||
-rw-r--r-- | types/xdg_shell/wlr_xdg_toplevel.c | 18 |
3 files changed, 20 insertions, 6 deletions
diff --git a/protocol/meson.build b/protocol/meson.build index 6ba4bb6e..726b01fc 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -1,5 +1,5 @@ wayland_protos = dependency('wayland-protocols', - version: '>=1.27', + version: '>=1.28', fallback: 'wayland-protocols', default_options: ['tests=false'], ) diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c index a03b90a1..0ba3c98e 100644 --- a/types/xdg_shell/wlr_xdg_surface.c +++ b/types/xdg_shell/wlr_xdg_surface.c @@ -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; } diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c index a3d7f2ef..2ef1379f 100644 --- a/types/xdg_shell/wlr_xdg_toplevel.c +++ b/types/xdg_shell/wlr_xdg_toplevel.c @@ -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; |