mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
input-method-v2: add popup_surface_from_resource()
This checks the resource type before casting its user data pointer.
This commit is contained in:
parent
fc9b58e84d
commit
00f1870d35
1 changed files with 9 additions and 1 deletions
|
@ -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…
Reference in a new issue