2013-12-28 20:53:12 -08:00
|
|
|
/*
|
2016-03-25 12:59:40 -07:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
2012-01-03 13:48:20 -08:00
|
|
|
*
|
2016-03-25 12:59:40 -07:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-01-03 13:48:20 -08:00
|
|
|
*
|
2016-03-25 12:59:40 -07:00
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2013-12-28 20:53:12 -08:00
|
|
|
*/
|
|
|
|
|
2014-01-01 14:44:28 -08:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "client.h"
|
2016-09-11 17:28:50 -07:00
|
|
|
#include "common/cursor.h"
|
|
|
|
#include "common/display.h"
|
2016-02-29 21:50:00 -08:00
|
|
|
#include "rdp.h"
|
2014-01-01 14:44:28 -08:00
|
|
|
#include "rdp_pointer.h"
|
2012-01-03 13:48:20 -08:00
|
|
|
|
2014-06-10 18:45:14 -07:00
|
|
|
#include <cairo/cairo.h>
|
2014-01-01 14:44:28 -08:00
|
|
|
#include <freerdp/freerdp.h>
|
2012-01-03 13:48:20 -08:00
|
|
|
#include <guacamole/client.h>
|
2014-06-10 18:45:14 -07:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2012-01-03 13:48:20 -08:00
|
|
|
|
|
|
|
void guac_rdp_pointer_new(rdpContext* context, rdpPointer* pointer) {
|
2012-02-16 14:46:08 -08:00
|
|
|
|
2012-01-03 13:48:20 -08:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2016-02-29 21:50:00 -08:00
|
|
|
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 14:46:08 -08:00
|
|
|
|
|
|
|
/* Allocate data for image */
|
2019-09-21 16:09:50 -07:00
|
|
|
unsigned char* data = _aligned_malloc(pointer->width * pointer->height * 4, 16);
|
2012-02-16 14:46:08 -08:00
|
|
|
|
|
|
|
cairo_surface_t* surface;
|
|
|
|
|
|
|
|
/* Convert to alpha cursor if mask data present */
|
|
|
|
if (pointer->andMaskData && pointer->xorMaskData)
|
2019-09-21 16:09:50 -07:00
|
|
|
freerdp_image_copy_from_pointer_data(data, 0, 0, 0,
|
|
|
|
pointer->width, pointer->height,
|
|
|
|
pointer->xorMaskData, pointer->lengthXorMask,
|
|
|
|
pointer->andMaskData, pointer->lengthAndMask,
|
|
|
|
pointer->xorBpp, &context->gdi->palette);
|
2012-02-16 14:46:08 -08:00
|
|
|
|
|
|
|
/* 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 */
|
2016-02-29 21:50:00 -08:00
|
|
|
guac_common_surface_draw(buffer->surface, 0, 0, surface);
|
2012-02-16 14:46:08 -08:00
|
|
|
|
|
|
|
/* Free surface */
|
|
|
|
cairo_surface_destroy(surface);
|
2019-09-21 16:09:50 -07:00
|
|
|
_aligned_free(data);
|
2012-02-16 14:46:08 -08:00
|
|
|
|
|
|
|
/* Remember buffer */
|
|
|
|
((guac_rdp_pointer*) pointer)->layer = buffer;
|
|
|
|
|
2012-01-03 13:48:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_pointer_set(rdpContext* context, rdpPointer* pointer) {
|
2012-02-16 14:46:08 -08:00
|
|
|
|
2012-01-03 13:48:20 -08:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2016-02-29 21:50:00 -08:00
|
|
|
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
|
2012-02-16 14:46:08 -08:00
|
|
|
|
|
|
|
/* Set cursor */
|
2016-02-29 21:50:00 -08:00
|
|
|
guac_common_cursor_set_surface(rdp_client->display->cursor,
|
|
|
|
pointer->xPos, pointer->yPos,
|
|
|
|
((guac_rdp_pointer*) pointer)->layer->surface);
|
2012-02-16 14:46:08 -08:00
|
|
|
|
2012-01-03 13:48:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_pointer_free(rdpContext* context, rdpPointer* pointer) {
|
2012-02-16 14:46:08 -08:00
|
|
|
|
2012-01-03 13:48:20 -08:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2016-02-29 21:50:00 -08:00
|
|
|
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 14:46:08 -08:00
|
|
|
|
2012-01-03 13:48:20 -08:00
|
|
|
}
|
|
|
|
|
2017-03-25 19:59:04 -07:00
|
|
|
BOOL guac_rdp_pointer_set_null(rdpContext* context) {
|
2012-06-09 20:36:34 -07:00
|
|
|
/* STUB */
|
2017-03-25 19:59:04 -07:00
|
|
|
return TRUE;
|
2012-05-23 12:11:39 +02:00
|
|
|
}
|
|
|
|
|
2017-03-25 19:59:04 -07:00
|
|
|
BOOL guac_rdp_pointer_set_default(rdpContext* context) {
|
2012-06-09 20:36:34 -07:00
|
|
|
/* STUB */
|
2017-03-25 19:59:04 -07:00
|
|
|
return TRUE;
|
2012-05-23 12:11:39 +02:00
|
|
|
}
|
|
|
|
|