compositor: replace role_data with role_resource

This increases type safety, makes it more obvious that role_data
must represent the role object, and will allow for automatic
cleanup when the resource is destroyed.
This commit is contained in:
Simon Ser 2023-06-23 14:23:27 +02:00
parent 00f1870d35
commit 89cb484220
10 changed files with 43 additions and 38 deletions

View file

@ -38,7 +38,7 @@ static struct wlr_xwayland_surface_v1 *xwl_surface_from_resource(
}
static void xwl_surface_role_commit(struct wlr_surface *surface) {
struct wlr_xwayland_surface_v1 *xwl_surface = surface->role_data;
struct wlr_xwayland_surface_v1 *xwl_surface = xwl_surface_from_resource(surface->role_resource);
if (xwl_surface->serial != 0 && !xwl_surface->added) {
xwl_surface->added = true;
@ -48,7 +48,7 @@ static void xwl_surface_role_commit(struct wlr_surface *surface) {
}
static void xwl_surface_role_destroy(struct wlr_surface *surface) {
struct wlr_xwayland_surface_v1 *xwl_surface = surface->role_data;
struct wlr_xwayland_surface_v1 *xwl_surface = xwl_surface_from_resource(surface->role_resource);
wl_list_remove(&xwl_surface->surface_destroy.link);
wl_list_remove(&xwl_surface->link);
wl_resource_set_user_data(xwl_surface->resource, NULL); // make inert
@ -131,7 +131,7 @@ static void shell_handle_get_xwayland_surface(struct wl_client *client,
wl_resource_set_implementation(xwl_surface->resource, &xwl_surface_impl,
xwl_surface, xwl_surface_handle_resource_destroy);
wlr_surface_set_role_object(surface, xwl_surface);
wlr_surface_set_role_object(surface, xwl_surface->resource);
wl_list_insert(&shell->surfaces, &xwl_surface->link);