xdg-foreign-v2: use error enum

A wayland-protocols patch [1] has added error codes for invalid
surfaces.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/57

Closes: https://github.com/swaywm/wlroots/issues/2600
master
Simon Ser 3 years ago committed by Kirill Primak
parent fb393ddf84
commit 3d6ca9942d

@ -30,19 +30,25 @@ static void xdg_imported_handle_destroy(struct wl_client *client,
static bool verify_is_toplevel(struct wl_resource *client_resource, static bool verify_is_toplevel(struct wl_resource *client_resource,
struct wlr_surface *surface) { struct wlr_surface *surface) {
if (wlr_surface_is_xdg_surface(surface)) { // Note: the error codes are the same for zxdg_exporter_v2 and
struct wlr_xdg_surface *xdg_surface = // zxdg_importer_v2
wlr_xdg_surface_from_wlr_surface(surface);
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) { if (!wlr_surface_is_xdg_surface(surface)) {
wl_resource_post_error(client_resource, -1, wl_resource_post_error(client_resource,
"surface must be an xdg_toplevel"); ZXDG_EXPORTER_V2_ERROR_INVALID_SURFACE,
return false; "surface must be an xdg_surface");
} return false;
} else { }
wl_resource_post_error(client_resource, -1,
"surface must be an xdg_surface"); struct wlr_xdg_surface *xdg_surface =
wlr_xdg_surface_from_wlr_surface(surface);
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
wl_resource_post_error(client_resource,
ZXDG_EXPORTER_V2_ERROR_INVALID_SURFACE,
"surface must be an xdg_toplevel");
return false; return false;
} }
return true; return true;
} }

Loading…
Cancel
Save