mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-01 22:58:40 -04:00
Add wl_resource_init and use it in libwayland implementations of data sharing and SHM
This commit adds a wl_resource_init function for initializing wl_resource structures similar to wl_client_add_object. From this commit forward, wl_resource structures should not be initialized manually, but should use wl_resource_init. In the event of a change to the wl_resource structure, this allows us to protect against regressions by filling in added fields with reasonable defaults. In this way, while changing wl_object or wl_resource still constitutes an ABI break, compositors following this rule will only need to be recompiled in order to properly link against the new version. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
ca5b1946cb
commit
bedc3432ff
4 changed files with 27 additions and 35 deletions
|
|
@ -128,12 +128,8 @@ shm_pool_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
|||
buffer->pool = pool;
|
||||
pool->refcount++;
|
||||
|
||||
buffer->buffer.resource.object.id = id;
|
||||
buffer->buffer.resource.object.interface = &wl_buffer_interface;
|
||||
buffer->buffer.resource.object.implementation = (void (**)(void))
|
||||
&shm_buffer_interface;
|
||||
|
||||
buffer->buffer.resource.data = buffer;
|
||||
wl_resource_init(&buffer->buffer.resource, &wl_buffer_interface,
|
||||
&shm_buffer_interface, id, buffer);
|
||||
buffer->buffer.resource.client = resource->client;
|
||||
buffer->buffer.resource.destroy = destroy_buffer;
|
||||
|
||||
|
|
@ -211,12 +207,8 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
|
|||
}
|
||||
close(fd);
|
||||
|
||||
pool->resource.object.id = id;
|
||||
pool->resource.object.interface = &wl_shm_pool_interface;
|
||||
pool->resource.object.implementation =
|
||||
(void (**)(void)) &shm_pool_interface;
|
||||
|
||||
pool->resource.data = pool;
|
||||
wl_resource_init(&pool->resource, &wl_shm_pool_interface,
|
||||
&shm_pool_interface, id, pool);
|
||||
pool->resource.client = client;
|
||||
pool->resource.destroy = destroy_pool;
|
||||
|
||||
|
|
@ -283,12 +275,8 @@ wl_shm_buffer_create(struct wl_client *client,
|
|||
buffer->offset = 0;
|
||||
buffer->pool = NULL;
|
||||
|
||||
buffer->buffer.resource.object.id = id;
|
||||
buffer->buffer.resource.object.interface = &wl_buffer_interface;
|
||||
buffer->buffer.resource.object.implementation = (void (**)(void))
|
||||
&shm_buffer_interface;
|
||||
|
||||
buffer->buffer.resource.data = buffer;
|
||||
wl_resource_init(&buffer->buffer.resource, &wl_buffer_interface,
|
||||
&shm_buffer_interface, id, buffer);
|
||||
buffer->buffer.resource.client = client;
|
||||
buffer->buffer.resource.destroy = destroy_buffer;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue