From 546e352374e3a1a4526c187126f8a669b1adfc4b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 15 Feb 2012 10:04:51 -0800 Subject: [PATCH] Refactor supporting buffered cursor instruction. --- protocols/vnc/include/client.h | 2 ++ protocols/vnc/src/client.c | 4 +++- protocols/vnc/src/vnc_handlers.c | 12 +++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/protocols/vnc/include/client.h b/protocols/vnc/include/client.h index 1eba8537..101d4a01 100644 --- a/protocols/vnc/include/client.h +++ b/protocols/vnc/include/client.h @@ -51,6 +51,8 @@ typedef struct vnc_guac_client_data { char* password; char* encodings; + guac_layer* cursor; + } vnc_guac_client_data; #endif diff --git a/protocols/vnc/src/client.c b/protocols/vnc/src/client.c index 8ed6a9f0..e49d1834 100644 --- a/protocols/vnc/src/client.c +++ b/protocols/vnc/src/client.c @@ -140,6 +140,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Set remaining client data */ guac_client_data->rfb_client = rfb_client; guac_client_data->copy_rect_used = 0; + guac_client_data->cursor = guac_client_alloc_buffer(client); /* Set handlers */ client->handle_messages = vnc_guac_client_handle_messages; @@ -155,7 +156,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) { guac_protocol_send_name(client->socket, rfb_client->desktopName); /* Send size */ - guac_protocol_send_size(client->socket, rfb_client->width, rfb_client->height); + guac_protocol_send_size(client->socket, + GUAC_DEFAULT_LAYER, rfb_client->width, rfb_client->height); return 0; diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c index 57ca9c3a..1aba3441 100644 --- a/protocols/vnc/src/vnc_handlers.c +++ b/protocols/vnc/src/vnc_handlers.c @@ -53,6 +53,7 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); guac_socket* socket = gc->socket; + const guac_layer* cursor_layer = ((vnc_guac_client_data*) gc->data)->cursor; /* Cairo image buffer */ int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); @@ -118,9 +119,13 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { } } - /* SEND CURSOR */ + /* Send cursor data*/ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, w, h, stride); - guac_protocol_send_cursor(socket, x, y, surface); + guac_protocol_send_png(socket, + GUAC_COMP_SRC, cursor_layer, 0, 0, surface); + + /* Update cursor */ + guac_protocol_send_cursor(socket, x, y, cursor_layer, 0, 0, w, h); /* Free surface */ cairo_surface_destroy(surface); @@ -244,7 +249,8 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; /* Send new size */ - guac_protocol_send_size(gc->socket, rfb_client->width, rfb_client->height); + guac_protocol_send_size(gc->socket, + GUAC_DEFAULT_LAYER, rfb_client->width, rfb_client->height); /* Use original, wrapped proc */ return guac_client_data->rfb_MallocFrameBuffer(rfb_client);