Implement hiding cursors
parent
1553c88f5e
commit
9c02e6afaf
|
@ -36,6 +36,10 @@ int cursor_encode(struct vec* dst, struct rfb_pixel_format* pixfmt,
|
||||||
|
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
|
// Empty cursor
|
||||||
|
if (!image)
|
||||||
|
return encode_rect_head(dst, RFB_ENCODING_CURSOR, 0, 0, 0, 0);
|
||||||
|
|
||||||
assert(width <= image->width);
|
assert(width <= image->width);
|
||||||
assert(height <= image->height);
|
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) {
|
if((int32_t)width == image->stride) {
|
||||||
pixel32_to_cpixel(dstdata, pixfmt, image->addr, &srcfmt, bpp, size);
|
pixel32_to_cpixel(dstdata, pixfmt, image->addr, &srcfmt, bpp, size);
|
||||||
} else {
|
} else {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (uint32_t y = 0; y < height; ++y) {
|
||||||
pixel32_to_cpixel(dstdata + y * bpp * width, pixfmt,
|
pixel32_to_cpixel(dstdata + y * bpp * width, pixfmt,
|
||||||
(uint32_t*)image->addr + y * image->stride,
|
(uint32_t*)image->addr + y * image->stride,
|
||||||
&srcfmt, bpp, width);
|
&srcfmt, bpp, width);
|
||||||
|
@ -76,7 +80,7 @@ int cursor_encode(struct vec* dst, struct rfb_pixel_format* pixfmt,
|
||||||
dstdata = dst->data;
|
dstdata = dst->data;
|
||||||
dstdata += dst->len;
|
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),
|
if (!extract_alpha_mask(dstdata + y * UDIV_UP(width, 8),
|
||||||
(uint32_t*)image->addr + y * image->stride,
|
(uint32_t*)image->addr + y * image->stride,
|
||||||
image->fourcc_format, width))
|
image->fourcc_format, width))
|
||||||
|
|
36
src/server.c
36
src/server.c
|
@ -467,9 +467,6 @@ static int on_client_set_pixel_format(struct nvnc_client* client)
|
||||||
|
|
||||||
memcpy(&client->pixfmt, fmt, sizeof(client->pixfmt));
|
memcpy(&client->pixfmt, fmt, sizeof(client->pixfmt));
|
||||||
|
|
||||||
if (client->has_pixfmt && client->cursor_seq)
|
|
||||||
client->cursor_seq--;
|
|
||||||
|
|
||||||
client->has_pixfmt = true;
|
client->has_pixfmt = true;
|
||||||
|
|
||||||
return 4 + sizeof(struct rfb_pixel_format);
|
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;
|
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;
|
struct vec payload;
|
||||||
vec_init(&payload, 4096);
|
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;
|
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_x = 0;
|
||||||
self->cursor.hotspot_y = 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++;
|
self->cursor_seq++;
|
||||||
|
|
||||||
struct nvnc_client* client;
|
struct nvnc_client* client;
|
||||||
LIST_FOREACH(client, &self->clients, link)
|
LIST_FOREACH(client, &self->clients, link)
|
||||||
process_fb_update_requests(client);
|
process_fb_update_requests(client);
|
||||||
|
|
||||||
log_debug("Setting cursor\n");
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue