mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-07 05:55:58 +01:00
buffer: add destroy event
This commit is contained in:
parent
7516a98167
commit
1674ca725c
2 changed files with 8 additions and 0 deletions
|
@ -25,6 +25,10 @@ struct wlr_buffer {
|
||||||
const struct wlr_buffer_impl *impl;
|
const struct wlr_buffer_impl *impl;
|
||||||
|
|
||||||
size_t n_refs;
|
size_t n_refs;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct wl_signal destroy;
|
||||||
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_buffer_init(struct wlr_buffer *buffer,
|
void wlr_buffer_init(struct wlr_buffer *buffer,
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
#include <wlr/types/wlr_buffer.h>
|
#include <wlr/types/wlr_buffer.h>
|
||||||
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
#include "util/signal.h"
|
||||||
|
|
||||||
void wlr_buffer_init(struct wlr_buffer *buffer,
|
void wlr_buffer_init(struct wlr_buffer *buffer,
|
||||||
const struct wlr_buffer_impl *impl) {
|
const struct wlr_buffer_impl *impl) {
|
||||||
assert(impl->destroy);
|
assert(impl->destroy);
|
||||||
buffer->impl = impl;
|
buffer->impl = impl;
|
||||||
buffer->n_refs = 1;
|
buffer->n_refs = 1;
|
||||||
|
wl_signal_init(&buffer->events.destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_buffer *wlr_buffer_ref(struct wlr_buffer *buffer) {
|
struct wlr_buffer *wlr_buffer_ref(struct wlr_buffer *buffer) {
|
||||||
|
@ -28,6 +30,8 @@ void wlr_buffer_unref(struct wlr_buffer *buffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_signal_emit_safe(&buffer->events.destroy, NULL);
|
||||||
|
|
||||||
buffer->impl->destroy(buffer);
|
buffer->impl->destroy(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue