Implement hiding cursors

pull/63/head
Andri Yngvason 2022-02-20 14:48:24 +00:00
parent 1553c88f5e
commit 9c02e6afaf
2 changed files with 19 additions and 25 deletions

View File

@ -36,6 +36,10 @@ int cursor_encode(struct vec* dst, struct rfb_pixel_format* pixfmt,
int rc = -1;
// Empty cursor
if (!image)
return encode_rect_head(dst, RFB_ENCODING_CURSOR, 0, 0, 0, 0);
assert(width <= image->width);
assert(height <= image->height);
@ -65,7 +69,7 @@ int cursor_encode(struct vec* dst, struct rfb_pixel_format* pixfmt,
if((int32_t)width == image->stride) {
pixel32_to_cpixel(dstdata, pixfmt, image->addr, &srcfmt, bpp, size);
} else {
for (int y = 0; y < height; ++y) {
for (uint32_t y = 0; y < height; ++y) {
pixel32_to_cpixel(dstdata + y * bpp * width, pixfmt,
(uint32_t*)image->addr + y * image->stride,
&srcfmt, bpp, width);
@ -76,7 +80,7 @@ int cursor_encode(struct vec* dst, struct rfb_pixel_format* pixfmt,
dstdata = dst->data;
dstdata += dst->len;
for (int y = 0; y < height; ++y) {
for (uint32_t y = 0; y < height; ++y) {
if (!extract_alpha_mask(dstdata + y * UDIV_UP(width, 8),
(uint32_t*)image->addr + y * image->stride,
image->fourcc_format, width))

View File

@ -467,9 +467,6 @@ static int on_client_set_pixel_format(struct nvnc_client* client)
memcpy(&client->pixfmt, fmt, sizeof(client->pixfmt));
if (client->has_pixfmt && client->cursor_seq)
client->cursor_seq--;
client->has_pixfmt = true;
return 4 + sizeof(struct rfb_pixel_format);
@ -526,12 +523,6 @@ static void send_cursor_update(struct nvnc_client* client)
{
struct nvnc* server = client->server;
if (!server->cursor.buffer) {
// TODO: Empty buffer means that no cursor should be visible
client->cursor_seq = server->cursor_seq;
return;
}
struct vec payload;
vec_init(&payload, 4096);
@ -1591,27 +1582,26 @@ void nvnc_set_cursor(struct nvnc* self, struct nvnc_fb* fb, uint16_t width,
}
self->cursor.buffer = fb;
if (!fb) {
if (fb) {
// TODO: Hash cursors to check if they actually changed?
nvnc_fb_ref(fb);
nvnc_fb_hold(fb);
self->cursor.width = width;
self->cursor.height = height;
self->cursor.hotspot_x = hotspot_x;
self->cursor.hotspot_y = hotspot_y;
} else {
self->cursor.width = width;
self->cursor.height = height;
self->cursor.hotspot_x = 0;
self->cursor.hotspot_y = 0;
return;
}
// TODO: Hash cursors to check if they actually changed?
nvnc_fb_ref(fb);
nvnc_fb_hold(fb);
self->cursor.width = width;
self->cursor.height = height;
self->cursor.hotspot_x = hotspot_x;
self->cursor.hotspot_y = hotspot_y;
self->cursor_seq++;
struct nvnc_client* client;
LIST_FOREACH(client, &self->clients, link)
process_fb_update_requests(client);
log_debug("Setting cursor\n");
}