From 7328ee303f72c67df38df67ed973bcab01a8afe9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 17 May 2012 13:04:38 -0700 Subject: [PATCH] Embed format information along with default cursor image data. Refactor default cursor set function out of rdp_pointer.h and into default_pointer.h. Add documentation. --- protocols/rdp/include/default_pointer.h | 32 ++++++++++++++++++- protocols/rdp/include/rdp_pointer.h | 1 - protocols/rdp/src/client.c | 1 + protocols/rdp/src/default_pointer.c | 42 +++++++++++++++++++++++++ protocols/rdp/src/rdp_pointer.c | 23 -------------- 5 files changed, 74 insertions(+), 25 deletions(-) diff --git a/protocols/rdp/include/default_pointer.h b/protocols/rdp/include/default_pointer.h index 68e02340..a45f3dee 100644 --- a/protocols/rdp/include/default_pointer.h +++ b/protocols/rdp/include/default_pointer.h @@ -38,9 +38,39 @@ #ifndef _GUAC_RDP_DEFAULT_POINTER_H #define _GUAC_RDP_DEFAULT_POINTER_H +#include +#include + /** - * Embedded 11x16 24-bit RGBA cursor graphic. + * Width of the embedded mouse cursor graphic. + */ +extern const int guac_rdp_default_pointer_width; + +/** + * Height of the embedded mouse cursor graphic. + */ +extern const int guac_rdp_default_pointer_height; + +/** + * Number of bytes in each row of the embedded mouse cursor graphic. + */ +extern const int guac_rdp_default_pointer_stride; + +/** + * The Cairo grapic format of the mouse cursor graphic. + */ +extern const cairo_format_t guac_rdp_default_pointer_format; + +/** + * Embedded mouse cursor graphic. */ extern unsigned char guac_rdp_default_pointer[]; +/** + * Set the cursor of the remote display to the embedded cursor graphic. + * + * @param client The guac_client to send the cursor to. + */ +void guac_rdp_pointer_set_default(guac_client* client); + #endif diff --git a/protocols/rdp/include/rdp_pointer.h b/protocols/rdp/include/rdp_pointer.h index 516f36ac..ff870913 100644 --- a/protocols/rdp/include/rdp_pointer.h +++ b/protocols/rdp/include/rdp_pointer.h @@ -59,6 +59,5 @@ typedef struct guac_rdp_pointer { void guac_rdp_pointer_new(rdpContext* context, rdpPointer* pointer); void guac_rdp_pointer_set(rdpContext* context, rdpPointer* pointer); void guac_rdp_pointer_free(rdpContext* context, rdpPointer* pointer); -void guac_rdp_pointer_set_default(guac_client* client); #endif diff --git a/protocols/rdp/src/client.c b/protocols/rdp/src/client.c index 690427c7..f82e75a8 100644 --- a/protocols/rdp/src/client.c +++ b/protocols/rdp/src/client.c @@ -66,6 +66,7 @@ #include "rdp_glyph.h" #include "rdp_pointer.h" #include "rdp_gdi.h" +#include "default_pointer.h" /* Client plugin arguments */ const char* GUAC_CLIENT_ARGS[] = { diff --git a/protocols/rdp/src/default_pointer.c b/protocols/rdp/src/default_pointer.c index c63c149a..b41ef2ac 100644 --- a/protocols/rdp/src/default_pointer.c +++ b/protocols/rdp/src/default_pointer.c @@ -35,11 +35,24 @@ * * ***** END LICENSE BLOCK ***** */ +#include +#include +#include +#include + /* Macros for prettying up the embedded image. */ #define X 0x00,0x00,0x00,0xFF #define O 0xFF,0xFF,0xFF,0xFF #define _ 0x00,0x00,0x00,0x00 +/* Dimensions */ +const int guac_rdp_default_pointer_width = 11; +const int guac_rdp_default_pointer_height = 16; + +/* Format */ +const cairo_format_t guac_rdp_default_pointer_format = CAIRO_FORMAT_ARGB32; +const int guac_rdp_default_pointer_stride = 44; + /* Embedded pointer graphic */ unsigned char guac_rdp_default_pointer[] = { @@ -62,3 +75,32 @@ unsigned char guac_rdp_default_pointer[] = { }; + +void guac_rdp_pointer_set_default(guac_client* client) { + + guac_socket* socket = client->socket; + + /* Draw to buffer */ + guac_layer* cursor = guac_client_alloc_buffer(client); + + cairo_surface_t* graphic = cairo_image_surface_create_for_data( + guac_rdp_default_pointer, + guac_rdp_default_pointer_format, + guac_rdp_default_pointer_width, + guac_rdp_default_pointer_height, + guac_rdp_default_pointer_stride); + + guac_protocol_send_png(socket, GUAC_COMP_SRC, cursor, 0, 0, graphic); + cairo_surface_destroy(graphic); + + /* Set cursor */ + guac_protocol_send_cursor(socket, 0, 0, cursor, + 0, 0, + guac_rdp_default_pointer_width, + guac_rdp_default_pointer_height); + + /* Free buffer */ + guac_client_free_buffer(client, cursor); + +} + diff --git a/protocols/rdp/src/rdp_pointer.c b/protocols/rdp/src/rdp_pointer.c index be2d5ea1..ac46aac9 100644 --- a/protocols/rdp/src/rdp_pointer.c +++ b/protocols/rdp/src/rdp_pointer.c @@ -101,26 +101,3 @@ void guac_rdp_pointer_free(rdpContext* context, rdpPointer* pointer) { } -void guac_rdp_pointer_set_default(guac_client* client) { - - guac_socket* socket = client->socket; - - /* Draw to buffer */ - guac_layer* cursor = guac_client_alloc_buffer(client); - - cairo_surface_t* graphic = cairo_image_surface_create_for_data( - guac_rdp_default_pointer, - CAIRO_FORMAT_ARGB32, - 11, 16, 11*4); - - guac_protocol_send_png(socket, GUAC_COMP_OVER, cursor, 0, 0, graphic); - cairo_surface_destroy(graphic); - - /* Set cursor */ - guac_protocol_send_cursor(socket, 0, 0, cursor, 0, 0, 11, 16); - - /* Free buffer */ - guac_client_free_buffer(client, cursor); - -} -