fb: Use special context pointer for release callback
parent
f566105ab5
commit
f5b0f508f0
|
@ -21,12 +21,14 @@
|
|||
#include <stdatomic.h>
|
||||
|
||||
#include "neatvnc.h"
|
||||
#include "common.h"
|
||||
|
||||
struct nvnc_fb {
|
||||
struct nvnc_common common;
|
||||
int ref;
|
||||
int hold_count;
|
||||
nvnc_fb_release_fn on_release;
|
||||
void* userdata;
|
||||
void* release_context;
|
||||
void* addr;
|
||||
enum nvnc_fb_flags flags;
|
||||
size_t size;
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef void (*nvnc_damage_fn)(struct pixman_region16* damage, void* userdata);
|
|||
typedef bool (*nvnc_auth_fn)(const char* username, const char* password,
|
||||
void* userdata);
|
||||
typedef void (*nvnc_cut_text_fn)(struct nvnc*, const char* text, uint32_t len);
|
||||
typedef void (*nvnc_fb_release_fn)(struct nvnc_fb*, void* userdata);
|
||||
typedef void (*nvnc_fb_release_fn)(struct nvnc_fb*, void* context);
|
||||
|
||||
extern const char nvnc_version[];
|
||||
|
||||
|
@ -89,7 +89,7 @@ void nvnc_fb_unref(struct nvnc_fb* fb);
|
|||
enum nvnc_fb_flags nvnc_fb_get_flags(const struct nvnc_fb*);
|
||||
void nvnc_fb_set_flags(struct nvnc_fb*, enum nvnc_fb_flags);
|
||||
void nvnc_fb_set_release_fn(struct nvnc_fb* fb, nvnc_fb_release_fn fn,
|
||||
void* userdata);
|
||||
void* context);
|
||||
|
||||
void* nvnc_fb_get_addr(const struct nvnc_fb* fb);
|
||||
uint16_t nvnc_fb_get_width(const struct nvnc_fb* fb);
|
||||
|
|
6
src/fb.c
6
src/fb.c
|
@ -112,10 +112,10 @@ void nvnc_fb_unref(struct nvnc_fb* fb)
|
|||
}
|
||||
|
||||
EXPORT
|
||||
void nvnc_fb_set_release_fn(struct nvnc_fb* fb, nvnc_fb_release_fn fn, void* userdata)
|
||||
void nvnc_fb_set_release_fn(struct nvnc_fb* fb, nvnc_fb_release_fn fn, void* context)
|
||||
{
|
||||
fb->on_release = fn;
|
||||
fb->userdata = userdata;
|
||||
fb->release_context = context;
|
||||
}
|
||||
|
||||
void nvnc_fb_hold(struct nvnc_fb* fb)
|
||||
|
@ -126,5 +126,5 @@ void nvnc_fb_hold(struct nvnc_fb* fb)
|
|||
void nvnc_fb_release(struct nvnc_fb* fb)
|
||||
{
|
||||
if (--fb->hold_count == 0 && fb->on_release)
|
||||
fb->on_release(fb, fb->userdata);
|
||||
fb->on_release(fb, fb->release_context);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue