guacamole-spice-protocol/src/protocols/rdp/rdp_pointer.c

107 lines
3.5 KiB
C
Raw Normal View History

/*
* Copyright (C) 2013 Glyptodon LLC
2012-01-03 21:48:20 +00:00
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
2012-01-03 21:48:20 +00:00
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
2012-01-03 21:48:20 +00:00
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
2014-01-01 22:44:28 +00:00
#include "config.h"
#include "client.h"
#include "guac_cursor.h"
#include "guac_display.h"
#include "rdp.h"
2014-01-01 22:44:28 +00:00
#include "rdp_pointer.h"
2012-01-03 21:48:20 +00:00
2014-06-11 01:45:14 +00:00
#include <cairo/cairo.h>
2014-01-01 22:44:28 +00:00
#include <freerdp/freerdp.h>
2012-01-03 21:48:20 +00:00
#include <guacamole/client.h>
2014-06-11 01:45:14 +00:00
#include <stdlib.h>
2012-01-03 21:48:20 +00:00
void guac_rdp_pointer_new(rdpContext* context, rdpPointer* pointer) {
2012-02-16 22:46:08 +00:00
2012-01-03 21:48:20 +00:00
guac_client* client = ((rdp_freerdp_context*) context)->client;
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
/* Allocate buffer */
guac_common_display_layer* buffer = guac_common_display_alloc_buffer(
rdp_client->display, pointer->width, pointer->height);
2012-02-16 22:46:08 +00:00
/* Allocate data for image */
unsigned char* data =
(unsigned char*) malloc(pointer->width * pointer->height * 4);
cairo_surface_t* surface;
/* Convert to alpha cursor if mask data present */
if (pointer->andMaskData && pointer->xorMaskData)
freerdp_alpha_cursor_convert(data,
pointer->xorMaskData, pointer->andMaskData,
pointer->width, pointer->height, pointer->xorBpp,
((rdp_freerdp_context*) context)->clrconv);
/* Create surface from image data */
surface = cairo_image_surface_create_for_data(
data, CAIRO_FORMAT_ARGB32,
pointer->width, pointer->height, 4*pointer->width);
/* Send surface to buffer */
guac_common_surface_draw(buffer->surface, 0, 0, surface);
2012-02-16 22:46:08 +00:00
/* Free surface */
cairo_surface_destroy(surface);
2012-02-17 18:04:00 +00:00
free(data);
2012-02-16 22:46:08 +00:00
/* Remember buffer */
((guac_rdp_pointer*) pointer)->layer = buffer;
2012-01-03 21:48:20 +00:00
}
void guac_rdp_pointer_set(rdpContext* context, rdpPointer* pointer) {
2012-02-16 22:46:08 +00:00
2012-01-03 21:48:20 +00:00
guac_client* client = ((rdp_freerdp_context*) context)->client;
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
2012-02-16 22:46:08 +00:00
/* Set cursor */
guac_common_cursor_set_surface(rdp_client->display->cursor,
pointer->xPos, pointer->yPos,
((guac_rdp_pointer*) pointer)->layer->surface);
2012-02-16 22:46:08 +00:00
2012-01-03 21:48:20 +00:00
}
void guac_rdp_pointer_free(rdpContext* context, rdpPointer* pointer) {
2012-02-16 22:46:08 +00:00
2012-01-03 21:48:20 +00:00
guac_client* client = ((rdp_freerdp_context*) context)->client;
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
guac_common_display_layer* buffer = ((guac_rdp_pointer*) pointer)->layer;
/* Free buffer */
guac_common_display_free_buffer(rdp_client->display, buffer);
2012-02-16 22:46:08 +00:00
2012-01-03 21:48:20 +00:00
}
void guac_rdp_pointer_set_null(rdpContext* context) {
/* STUB */
}
void guac_rdp_pointer_set_default(rdpContext* context) {
/* STUB */
}