Pass nvnc_client to cut-text callback
parent
79f26924ea
commit
8f979c9928
|
@ -110,7 +110,8 @@ typedef void (*nvnc_client_fn)(struct nvnc_client*);
|
||||||
typedef void (*nvnc_damage_fn)(struct pixman_region16* damage, void* userdata);
|
typedef void (*nvnc_damage_fn)(struct pixman_region16* damage, void* userdata);
|
||||||
typedef bool (*nvnc_auth_fn)(const char* username, const char* password,
|
typedef bool (*nvnc_auth_fn)(const char* username, const char* password,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
typedef void (*nvnc_cut_text_fn)(struct nvnc*, const char* text, uint32_t len);
|
typedef void (*nvnc_cut_text_fn)(struct nvnc_client*, const char* text,
|
||||||
|
uint32_t len);
|
||||||
typedef void (*nvnc_fb_release_fn)(struct nvnc_fb*, void* context);
|
typedef void (*nvnc_fb_release_fn)(struct nvnc_fb*, void* context);
|
||||||
typedef struct nvnc_fb* (*nvnc_fb_alloc_fn)(uint16_t width, uint16_t height,
|
typedef struct nvnc_fb* (*nvnc_fb_alloc_fn)(uint16_t width, uint16_t height,
|
||||||
uint32_t format, uint16_t stride);
|
uint32_t format, uint16_t stride);
|
||||||
|
@ -137,6 +138,7 @@ const char* nvnc_client_get_auth_username(const struct nvnc_client* client);
|
||||||
struct nvnc_client* nvnc_client_first(struct nvnc* self);
|
struct nvnc_client* nvnc_client_first(struct nvnc* self);
|
||||||
struct nvnc_client* nvnc_client_next(struct nvnc_client* client);
|
struct nvnc_client* nvnc_client_next(struct nvnc_client* client);
|
||||||
|
|
||||||
|
|
||||||
void nvnc_set_name(struct nvnc* self, const char* name);
|
void nvnc_set_name(struct nvnc* self, const char* name);
|
||||||
|
|
||||||
void nvnc_set_key_fn(struct nvnc* self, nvnc_key_fn);
|
void nvnc_set_key_fn(struct nvnc* self, nvnc_key_fn);
|
||||||
|
@ -145,7 +147,7 @@ void nvnc_set_pointer_fn(struct nvnc* self, nvnc_pointer_fn);
|
||||||
void nvnc_set_fb_req_fn(struct nvnc* self, nvnc_fb_req_fn);
|
void nvnc_set_fb_req_fn(struct nvnc* self, nvnc_fb_req_fn);
|
||||||
void nvnc_set_new_client_fn(struct nvnc* self, nvnc_client_fn);
|
void nvnc_set_new_client_fn(struct nvnc* self, nvnc_client_fn);
|
||||||
void nvnc_set_client_cleanup_fn(struct nvnc_client* self, nvnc_client_fn fn);
|
void nvnc_set_client_cleanup_fn(struct nvnc_client* self, nvnc_client_fn fn);
|
||||||
void nvnc_set_cut_text_receive_fn(struct nvnc* self, nvnc_cut_text_fn fn);
|
void nvnc_set_cut_text_fn(struct nvnc*, nvnc_cut_text_fn fn);
|
||||||
|
|
||||||
bool nvnc_has_auth(void);
|
bool nvnc_has_auth(void);
|
||||||
int nvnc_enable_auth(struct nvnc* self, const char* privkey_path,
|
int nvnc_enable_auth(struct nvnc* self, const char* privkey_path,
|
||||||
|
|
13
src/server.c
13
src/server.c
|
@ -852,8 +852,6 @@ void nvnc_send_cut_text(struct nvnc* server, const char* text, uint32_t len)
|
||||||
|
|
||||||
static int on_client_cut_text(struct nvnc_client* client)
|
static int on_client_cut_text(struct nvnc_client* client)
|
||||||
{
|
{
|
||||||
struct nvnc* server = client->server;
|
|
||||||
nvnc_cut_text_fn fn = server->cut_text_fn;
|
|
||||||
struct rfb_cut_text_msg* msg =
|
struct rfb_cut_text_msg* msg =
|
||||||
(struct rfb_cut_text_msg*)(client->msg_buffer +
|
(struct rfb_cut_text_msg*)(client->msg_buffer +
|
||||||
client->buffer_index);
|
client->buffer_index);
|
||||||
|
@ -878,8 +876,9 @@ static int on_client_cut_text(struct nvnc_client* client)
|
||||||
size_t msg_size = sizeof(*msg) + length;
|
size_t msg_size = sizeof(*msg) + length;
|
||||||
|
|
||||||
if (msg_size <= left_to_process) {
|
if (msg_size <= left_to_process) {
|
||||||
|
nvnc_cut_text_fn fn = client->server->cut_text_fn;
|
||||||
if (fn)
|
if (fn)
|
||||||
fn(server, msg->text, length);
|
fn(client, msg->text, length);
|
||||||
|
|
||||||
return msg_size;
|
return msg_size;
|
||||||
}
|
}
|
||||||
|
@ -906,9 +905,6 @@ static int on_client_cut_text(struct nvnc_client* client)
|
||||||
|
|
||||||
static void process_big_cut_text(struct nvnc_client* client)
|
static void process_big_cut_text(struct nvnc_client* client)
|
||||||
{
|
{
|
||||||
struct nvnc* server = client->server;
|
|
||||||
nvnc_cut_text_fn fn = server->cut_text_fn;
|
|
||||||
|
|
||||||
assert(client->cut_text.length > client->cut_text.index);
|
assert(client->cut_text.length > client->cut_text.index);
|
||||||
|
|
||||||
void* start = client->cut_text.buffer + client->cut_text.index;
|
void* start = client->cut_text.buffer + client->cut_text.index;
|
||||||
|
@ -937,8 +933,9 @@ static void process_big_cut_text(struct nvnc_client* client)
|
||||||
if (client->cut_text.index != client->cut_text.length)
|
if (client->cut_text.index != client->cut_text.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
nvnc_cut_text_fn fn = client->server->cut_text_fn;
|
||||||
if (fn)
|
if (fn)
|
||||||
fn(server, client->cut_text.buffer, client->cut_text.length);
|
fn(client, client->cut_text.buffer, client->cut_text.length);
|
||||||
|
|
||||||
free(client->cut_text.buffer);
|
free(client->cut_text.buffer);
|
||||||
client->cut_text.buffer = NULL;
|
client->cut_text.buffer = NULL;
|
||||||
|
@ -1556,7 +1553,7 @@ void nvnc_set_client_cleanup_fn(struct nvnc_client* self, nvnc_client_fn fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT
|
EXPORT
|
||||||
void nvnc_set_cut_text_receive_fn(struct nvnc* self, nvnc_cut_text_fn fn)
|
void nvnc_set_cut_text_fn(struct nvnc* self, nvnc_cut_text_fn fn)
|
||||||
{
|
{
|
||||||
self->cut_text_fn = fn;
|
self->cut_text_fn = fn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue