diff options
author | Simon Ser <contact@emersion.fr> | 2020-02-28 13:14:06 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-04-02 15:03:43 +0200 |
commit | 1674ca725c150e81917c2250571c2607e68ebc6e (patch) | |
tree | 209d50235accf3398f7d9d87745904434fa4dcd2 | |
parent | 7516a98167326350fb6e1906224bbff04fbf4c62 (diff) |
buffer: add destroy event
-rw-r--r-- | include/wlr/types/wlr_buffer.h | 4 | ||||
-rw-r--r-- | types/wlr_buffer.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_buffer.h b/include/wlr/types/wlr_buffer.h index 6a49a1bf..d6a98f4b 100644 --- a/include/wlr/types/wlr_buffer.h +++ b/include/wlr/types/wlr_buffer.h @@ -25,6 +25,10 @@ struct wlr_buffer { const struct wlr_buffer_impl *impl; size_t n_refs; + + struct { + struct wl_signal destroy; + } events; }; void wlr_buffer_init(struct wlr_buffer *buffer, diff --git a/types/wlr_buffer.c b/types/wlr_buffer.c index 0cdb3444..3d6ae719 100644 --- a/types/wlr_buffer.c +++ b/types/wlr_buffer.c @@ -4,12 +4,14 @@ #include <wlr/types/wlr_buffer.h> #include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/util/log.h> +#include "util/signal.h" void wlr_buffer_init(struct wlr_buffer *buffer, const struct wlr_buffer_impl *impl) { assert(impl->destroy); buffer->impl = impl; buffer->n_refs = 1; + wl_signal_init(&buffer->events.destroy); } struct wlr_buffer *wlr_buffer_ref(struct wlr_buffer *buffer) { @@ -28,6 +30,8 @@ void wlr_buffer_unref(struct wlr_buffer *buffer) { return; } + wlr_signal_emit_safe(&buffer->events.destroy, NULL); + buffer->impl->destroy(buffer); } |