mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
tests/wayland-test-clients: Destroy WaylandBuffers when released
Instead of forcing every user of WaylandBuffer to create a listener and destroy the wl_resource and the WaylandBuffer object, provide a default listener which does it for the user. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3371>
This commit is contained in:
parent
628f12a48b
commit
0930282baa
@ -793,6 +793,20 @@ wayland_buffer_init (WaylandBuffer *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
handle_buffer_release (void *user_data,
|
||||
struct wl_buffer *buffer_resource)
|
||||
{
|
||||
WaylandBuffer *buffer = WAYLAND_BUFFER (user_data);
|
||||
|
||||
wl_buffer_destroy (buffer_resource);
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
|
||||
static const struct wl_buffer_listener default_buffer_listener = {
|
||||
handle_buffer_release
|
||||
};
|
||||
|
||||
WaylandBuffer *
|
||||
wayland_buffer_create (WaylandDisplay *display,
|
||||
const struct wl_buffer_listener *listener,
|
||||
@ -824,6 +838,9 @@ wayland_buffer_create (WaylandDisplay *display,
|
||||
if (!wayland_buffer_allocate (buffer, n_modifiers, modifiers, bo_flags))
|
||||
return NULL;
|
||||
|
||||
if (!listener)
|
||||
listener = &default_buffer_listener;
|
||||
|
||||
wl_buffer_add_listener (priv->buffer, listener, buffer);
|
||||
|
||||
return g_steal_pointer (&buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user