vnc: Add cut-text events

pull/3/head
Andri Yngvason 2020-12-06 19:52:02 +00:00
parent 67676b224e
commit 86283fd8d1
2 changed files with 21 additions and 0 deletions

View File

@ -17,6 +17,7 @@
#pragma once
#include <stdbool.h>
#include <unistd.h>
#include <pixman.h>
#include <wayland-client.h>
#include <rfb/rfbclient.h>
@ -26,6 +27,7 @@ struct vnc_client {
int (*alloc_fb)(struct vnc_client*);
void (*update_fb)(struct vnc_client*);
void (*cut_text)(struct vnc_client*, const char*, size_t);
void* userdata;
struct pixman_region16 damage;
@ -54,3 +56,5 @@ void vnc_client_send_keyboard_event(struct vnc_client* self, uint32_t symbol,
void vnc_client_set_encodings(struct vnc_client* self, const char* encodings);
void vnc_client_set_quality_level(struct vnc_client* self, int value);
void vnc_client_set_compression_level(struct vnc_client* self, int value);
void vnc_client_send_cut_text(struct vnc_client* self, const char* text,
size_t len);

View File

@ -56,6 +56,15 @@ static void vnc_client_finish_update(rfbClient* client)
pixman_region_clear(&self->damage);
}
static void vnc_client_got_cut_text(rfbClient* client, const char* text,
int len)
{
struct vnc_client* self = rfbClientGetClientData(client, NULL);
assert(self);
self->cut_text(self, text, len);
}
struct vnc_client* vnc_client_create(void)
{
struct vnc_client* self = calloc(1, sizeof(*self));
@ -80,6 +89,7 @@ struct vnc_client* vnc_client_create(void)
client->MallocFrameBuffer = vnc_client_alloc_fb;
client->GotFrameBufferUpdate = vnc_client_update_box;
client->FinishedFrameBufferUpdate = vnc_client_finish_update;
client->GotXCutText = vnc_client_got_cut_text;
return self;
@ -240,3 +250,10 @@ void vnc_client_set_compression_level(struct vnc_client* self, int value)
{
self->client->appData.compressLevel = value;
}
void vnc_client_send_cut_text(struct vnc_client* self, const char* text,
size_t len)
{
// libvncclient doesn't modify text, so typecast is OK.
SendClientCutText(self->client, (char*)text, len);
}