Ticket #33: Allow parameter for setting remote or local cursor.

This commit is contained in:
James Muehlner 2013-08-26 21:50:54 -07:00
parent c6a6c5b681
commit 775668ad37
4 changed files with 187 additions and 9 deletions

View File

@ -44,14 +44,16 @@ lib_LTLIBRARIES = libguac-client-vnc.la
libguac_client_vnc_la_SOURCES = \
client.c \
convert.c \
default_pointer.c \
guac_handlers.c \
vnc_handlers.c
vnc_handlers.c
noinst_HEADERS = \
client.h \
convert.h \
guac_handlers.h \
vnc_handlers.h
noinst_HEADERS = \
client.h \
convert.h \
default_pointer.h \
guac_handlers.h \
vnc_handlers.h
# Optional PulseAudio support
if ENABLE_PULSE

View File

@ -19,7 +19,7 @@
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Contributor(s): James Muehlner
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -48,6 +48,7 @@
#include "client.h"
#include "vnc_handlers.h"
#include "guac_handlers.h"
#include "default_pointer.h"
#ifdef ENABLE_PULSE
#include "pulse.h"
@ -62,7 +63,7 @@ const char* GUAC_CLIENT_ARGS[] = {
"password",
"swap-red-blue",
"color-depth",
"cursor",
#ifdef ENABLE_VNC_REPEATER
"dest-host",
"dest-port",
@ -85,7 +86,7 @@ enum VNC_ARGS_IDX {
IDX_PASSWORD,
IDX_SWAP_RED_BLUE,
IDX_COLOR_DEPTH,
IDX_CURSOR,
#ifdef ENABLE_VNC_REPEATER
IDX_DEST_HOST,
IDX_DEST_PORT,
@ -109,6 +110,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
vnc_guac_client_data* guac_client_data;
int read_only;
int remote_cursor;
/* Set up libvncclient logging */
rfbClientLog = guac_vnc_client_log_info;
@ -129,6 +131,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* Set read-only flag */
read_only = (strcmp(argv[IDX_READ_ONLY], "true") == 0);
/* Set remote cursor flag */
remote_cursor = (strcmp(argv[IDX_CURSOR], "remote") == 0);
/* Set red/blue swap flag */
guac_client_data->swap_red_blue = (strcmp(argv[IDX_SWAP_RED_BLUE], "true") == 0);
@ -156,6 +161,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
rfb_client->GotXCutText = guac_vnc_cut_text;
}
/* Set remote cursor */
if(remote_cursor) {
rfb_client->appData.useRemoteCursor = TRUE;
guac_vnc_set_default_pointer(client);
}
/* Password */
rfb_client->GetPassword = guac_vnc_get_password;

View File

@ -0,0 +1,89 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is libguac-client-vnc.
*
* The Initial Developer of the Original Code is
* Michael Jumper.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): James Muehlner
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** 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. */
#define O 0xFF,0xFF,0xFF,0xFF
/* Dimensions */
const int guac_vnc_default_pointer_width = 1;
const int guac_vnc_default_pointer_height = 1;
/* Format */
const cairo_format_t guac_vnc_default_pointer_format = CAIRO_FORMAT_ARGB32;
const int guac_vnc_default_pointer_stride = 44;
/* Embedded pointer graphic */
unsigned char guac_vnc_default_pointer[] = {
O
};
void guac_vnc_set_default_pointer(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_vnc_default_pointer,
guac_vnc_default_pointer_format,
guac_vnc_default_pointer_width,
guac_vnc_default_pointer_height,
guac_vnc_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_vnc_default_pointer_width,
guac_vnc_default_pointer_height);
/* Free buffer */
guac_client_free_buffer(client, cursor);
}

View File

@ -0,0 +1,76 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is libguac-client-vnc.
*
* The Initial Developer of the Original Code is
* Michael Jumper.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): James Muehlner
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _GUAC_VNC_DEFAULT_POINTER_H
#define _GUAC_VNC_DEFAULT_POINTER_H
#include <cairo/cairo.h>
#include <guacamole/client.h>
/**
* Width of the embedded mouse cursor graphic.
*/
extern const int guac_vnc_default_pointer_width;
/**
* Height of the embedded mouse cursor graphic.
*/
extern const int guac_vnc_default_pointer_height;
/**
* Number of bytes in each row of the embedded mouse cursor graphic.
*/
extern const int guac_vnc_default_pointer_stride;
/**
* The Cairo grapic format of the mouse cursor graphic.
*/
extern const cairo_format_t guac_vnc_default_pointer_format;
/**
* Embedded mouse cursor graphic.
*/
extern unsigned char guac_vnc_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_vnc_set_default_pointer(guac_client* client);
#endif