input-method-v2: add popup_surface_from_resource()

This checks the resource type before casting its user data pointer.
master
Simon Ser 1 year ago
parent fc9b58e84d
commit 00f1870d35

@ -165,9 +165,17 @@ struct wlr_input_popup_surface_v2 *wlr_input_popup_surface_v2_try_from_wlr_surfa
return (struct wlr_input_popup_surface_v2 *)surface->role_data; return (struct wlr_input_popup_surface_v2 *)surface->role_data;
} }
static const struct zwp_input_popup_surface_v2_interface input_popup_impl;
static struct wlr_input_popup_surface_v2 *popup_surface_from_resource(struct wl_resource *resource) {
assert(wl_resource_instance_of(resource, &zwp_input_popup_surface_v2_interface,
&input_popup_impl));
return wl_resource_get_user_data(resource);
}
static void popup_resource_destroy(struct wl_resource *resource) { static void popup_resource_destroy(struct wl_resource *resource) {
struct wlr_input_popup_surface_v2 *popup_surface = struct wlr_input_popup_surface_v2 *popup_surface =
wl_resource_get_user_data(resource); popup_surface_from_resource(resource);
if (popup_surface != NULL) { if (popup_surface != NULL) {
wlr_surface_destroy_role_object(popup_surface->surface); wlr_surface_destroy_role_object(popup_surface->surface);
} }

Loading…
Cancel
Save