diff options
author | Simon Ser <contact@emersion.fr> | 2023-06-23 14:14:36 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-06-23 14:14:36 +0200 |
commit | 00f1870d3566041e2e1ef2502dc52140f23bc556 (patch) | |
tree | e3e43f055483bfa82ab00e3e4eaf4cc8ceb89804 | |
parent | fc9b58e84da2303148757cad4a83eb17d974edae (diff) |
input-method-v2: add popup_surface_from_resource()
This checks the resource type before casting its user data pointer.
-rw-r--r-- | types/wlr_input_method_v2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/types/wlr_input_method_v2.c b/types/wlr_input_method_v2.c index 856abb4f..f8c9d442 100644 --- a/types/wlr_input_method_v2.c +++ b/types/wlr_input_method_v2.c @@ -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; } +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) { struct wlr_input_popup_surface_v2 *popup_surface = - wl_resource_get_user_data(resource); + popup_surface_from_resource(resource); if (popup_surface != NULL) { wlr_surface_destroy_role_object(popup_surface->surface); } |