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.

This commit is contained in:
Michael Jumper 2012-05-17 13:04:38 -07:00
parent bb5f4d61d9
commit 7328ee303f
5 changed files with 74 additions and 25 deletions

View File

@ -38,9 +38,39 @@
#ifndef _GUAC_RDP_DEFAULT_POINTER_H #ifndef _GUAC_RDP_DEFAULT_POINTER_H
#define _GUAC_RDP_DEFAULT_POINTER_H #define _GUAC_RDP_DEFAULT_POINTER_H
#include <cairo/cairo.h>
#include <guacamole/client.h>
/** /**
* 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[]; 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 #endif

View File

@ -59,6 +59,5 @@ typedef struct guac_rdp_pointer {
void guac_rdp_pointer_new(rdpContext* context, rdpPointer* pointer); void guac_rdp_pointer_new(rdpContext* context, rdpPointer* pointer);
void guac_rdp_pointer_set(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_free(rdpContext* context, rdpPointer* pointer);
void guac_rdp_pointer_set_default(guac_client* client);
#endif #endif

View File

@ -66,6 +66,7 @@
#include "rdp_glyph.h" #include "rdp_glyph.h"
#include "rdp_pointer.h" #include "rdp_pointer.h"
#include "rdp_gdi.h" #include "rdp_gdi.h"
#include "default_pointer.h"
/* Client plugin arguments */ /* Client plugin arguments */
const char* GUAC_CLIENT_ARGS[] = { const char* GUAC_CLIENT_ARGS[] = {

View File

@ -35,11 +35,24 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include <cairo/cairo.h>
#include <guacamole/client.h>
#include <guacamole/protocol.h>
#include <guacamole/socket.h>
/* Macros for prettying up the embedded image. */ /* Macros for prettying up the embedded image. */
#define X 0x00,0x00,0x00,0xFF #define X 0x00,0x00,0x00,0xFF
#define O 0xFF,0xFF,0xFF,0xFF #define O 0xFF,0xFF,0xFF,0xFF
#define _ 0x00,0x00,0x00,0x00 #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 */ /* Embedded pointer graphic */
unsigned char guac_rdp_default_pointer[] = { 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);
}

View File

@ -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);
}