From 93639cbf128e4b37ad2b535630f18fe51cc22001 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 6 Jan 2014 16:18:54 -0800 Subject: [PATCH] Move VNC pointers to common. --- Makefile.am | 2 +- configure.ac | 2 ++ src/common/Makefile.am | 16 ++++++++---- .../dot_cursor.c => common/guac_dot_cursor.c} | 26 +++++++++---------- .../dot_cursor.h => common/guac_dot_cursor.h} | 16 ++++++------ .../guac_pointer_cursor.c} | 26 +++++++++---------- .../guac_pointer_cursor.h} | 16 ++++++------ src/protocols/vnc/Makefile.am | 14 +++++----- src/protocols/vnc/client.c | 8 +++--- 9 files changed, 68 insertions(+), 58 deletions(-) rename src/{protocols/vnc/dot_cursor.c => common/guac_dot_cursor.c} (77%) rename src/{protocols/vnc/dot_cursor.h => common/guac_dot_cursor.h} (81%) rename src/{protocols/vnc/pointer_cursor.c => common/guac_pointer_cursor.c} (78%) rename src/{protocols/vnc/pointer_cursor.h => common/guac_pointer_cursor.h} (80%) diff --git a/Makefile.am b/Makefile.am index b7f274b3..43759126 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,8 +32,8 @@ DIST_SUBDIRS = \ tests SUBDIRS = \ - src/common \ src/libguac \ + src/common \ src/guacd \ tests diff --git a/configure.ac b/configure.ac index 450a38b2..83382e23 100644 --- a/configure.ac +++ b/configure.ac @@ -92,6 +92,8 @@ AC_TYPE_SSIZE_T # Bundled libguac AC_SUBST([LIBGUAC_LTLIB], '$(top_builddir)/src/libguac/libguac.la') AC_SUBST([LIBGUAC_INCLUDE], '-I$(top_srcdir)/src/libguac') +AC_SUBST([COMMON_LTLIB], '$(top_builddir)/src/common/libguac_common.la') +AC_SUBST([COMMON_INCLUDE], '-I$(top_builddir)/src/common') # Options AC_ARG_WITH(init_dir, diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 17782316..4fc272ed 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -22,15 +22,21 @@ AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 -AM_CFLAGS = -Werror -Wall -pedantic +AM_CFLAGS = -Werror -Wall -pedantic @LIBGUAC_INCLUDE@ noinst_LTLIBRARIES = libguac_common.la -noinst_HEADERS = \ - guac_io.h \ - guac_list.h +noinst_HEADERS = \ + guac_io.h \ + guac_dot_cursor.c \ + guac_list.h \ + guac_pointer_cursor.c libguac_common_la_SOURCES = \ guac_io.c \ - guac_list.c + guac_dot_cursor.c \ + guac_list.c \ + guac_pointer_cursor.c + +libguac_common_la_LIBADD = @LIBGUAC_LTLIB@ diff --git a/src/protocols/vnc/dot_cursor.c b/src/common/guac_dot_cursor.c similarity index 77% rename from src/protocols/vnc/dot_cursor.c rename to src/common/guac_dot_cursor.c index b0a9457f..da062987 100644 --- a/src/protocols/vnc/dot_cursor.c +++ b/src/common/guac_dot_cursor.c @@ -33,15 +33,15 @@ #define _ 0x00,0x00,0x00,0x00 /* Dimensions */ -const int guac_vnc_dot_cursor_width = 5; -const int guac_vnc_dot_cursor_height = 5; +const int guac_common_dot_cursor_width = 5; +const int guac_common_dot_cursor_height = 5; /* Format */ -const cairo_format_t guac_vnc_dot_cursor_format = CAIRO_FORMAT_ARGB32; -const int guac_vnc_dot_cursor_stride = 20; +const cairo_format_t guac_common_dot_cursor_format = CAIRO_FORMAT_ARGB32; +const int guac_common_dot_cursor_stride = 20; /* Embedded pointer graphic */ -unsigned char guac_vnc_dot_cursor[] = { +unsigned char guac_common_dot_cursor[] = { _,O,O,O,_, O,X,X,X,O, @@ -51,7 +51,7 @@ unsigned char guac_vnc_dot_cursor[] = { }; -void guac_vnc_set_dot_cursor(guac_client* client) { +void guac_common_set_dot_cursor(guac_client* client) { guac_socket* socket = client->socket; @@ -59,11 +59,11 @@ void guac_vnc_set_dot_cursor(guac_client* client) { guac_layer* cursor = guac_client_alloc_buffer(client); cairo_surface_t* graphic = cairo_image_surface_create_for_data( - guac_vnc_dot_cursor, - guac_vnc_dot_cursor_format, - guac_vnc_dot_cursor_width, - guac_vnc_dot_cursor_height, - guac_vnc_dot_cursor_stride); + guac_common_dot_cursor, + guac_common_dot_cursor_format, + guac_common_dot_cursor_width, + guac_common_dot_cursor_height, + guac_common_dot_cursor_stride); guac_protocol_send_png(socket, GUAC_COMP_SRC, cursor, 0, 0, graphic); cairo_surface_destroy(graphic); @@ -71,8 +71,8 @@ void guac_vnc_set_dot_cursor(guac_client* client) { /* Set cursor */ guac_protocol_send_cursor(socket, 2, 2, cursor, 0, 0, - guac_vnc_dot_cursor_width, - guac_vnc_dot_cursor_height); + guac_common_dot_cursor_width, + guac_common_dot_cursor_height); /* Free buffer */ guac_client_free_buffer(client, cursor); diff --git a/src/protocols/vnc/dot_cursor.h b/src/common/guac_dot_cursor.h similarity index 81% rename from src/protocols/vnc/dot_cursor.h rename to src/common/guac_dot_cursor.h index e80e37a4..d3ab2b28 100644 --- a/src/protocols/vnc/dot_cursor.h +++ b/src/common/guac_dot_cursor.h @@ -21,8 +21,8 @@ */ -#ifndef _GUAC_VNC_DOT_CURSOR_H -#define _GUAC_VNC_DOT_CURSOR_H +#ifndef _GUAC_COMMON_DOT_CURSOR_H +#define _GUAC_COMMON_DOT_CURSOR_H #include "config.h" @@ -32,33 +32,33 @@ /** * Width of the embedded mouse cursor graphic. */ -extern const int guac_vnc_dot_cursor_width; +extern const int guac_common_dot_cursor_width; /** * Height of the embedded mouse cursor graphic. */ -extern const int guac_vnc_dot_cursor_height; +extern const int guac_common_dot_cursor_height; /** * Number of bytes in each row of the embedded mouse cursor graphic. */ -extern const int guac_vnc_dot_cursor_stride; +extern const int guac_common_dot_cursor_stride; /** * The Cairo grapic format of the mouse cursor graphic. */ -extern const cairo_format_t guac_vnc_dot_cursor_format; +extern const cairo_format_t guac_common_dot_cursor_format; /** * Embedded mouse cursor graphic. */ -extern unsigned char guac_vnc_dot_cursor[]; +extern unsigned char guac_common_dot_cursor[]; /** * 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_dot_cursor(guac_client* client); +void guac_common_set_dot_cursor(guac_client* client); #endif diff --git a/src/protocols/vnc/pointer_cursor.c b/src/common/guac_pointer_cursor.c similarity index 78% rename from src/protocols/vnc/pointer_cursor.c rename to src/common/guac_pointer_cursor.c index 7c549a7f..3a87378f 100644 --- a/src/protocols/vnc/pointer_cursor.c +++ b/src/common/guac_pointer_cursor.c @@ -33,15 +33,15 @@ #define _ 0x00,0x00,0x00,0x00 /* Dimensions */ -const int guac_vnc_pointer_cursor_width = 11; -const int guac_vnc_pointer_cursor_height = 16; +const int guac_common_pointer_cursor_width = 11; +const int guac_common_pointer_cursor_height = 16; /* Format */ -const cairo_format_t guac_vnc_pointer_cursor_format = CAIRO_FORMAT_ARGB32; -const int guac_vnc_pointer_cursor_stride = 44; +const cairo_format_t guac_common_pointer_cursor_format = CAIRO_FORMAT_ARGB32; +const int guac_common_pointer_cursor_stride = 44; /* Embedded pointer graphic */ -unsigned char guac_vnc_pointer_cursor[] = { +unsigned char guac_common_pointer_cursor[] = { O,_,_,_,_,_,_,_,_,_,_, O,O,_,_,_,_,_,_,_,_,_, @@ -62,7 +62,7 @@ unsigned char guac_vnc_pointer_cursor[] = { }; -void guac_vnc_set_pointer_cursor(guac_client* client) { +void guac_common_set_pointer_cursor(guac_client* client) { guac_socket* socket = client->socket; @@ -70,11 +70,11 @@ void guac_vnc_set_pointer_cursor(guac_client* client) { guac_layer* cursor = guac_client_alloc_buffer(client); cairo_surface_t* graphic = cairo_image_surface_create_for_data( - guac_vnc_pointer_cursor, - guac_vnc_pointer_cursor_format, - guac_vnc_pointer_cursor_width, - guac_vnc_pointer_cursor_height, - guac_vnc_pointer_cursor_stride); + guac_common_pointer_cursor, + guac_common_pointer_cursor_format, + guac_common_pointer_cursor_width, + guac_common_pointer_cursor_height, + guac_common_pointer_cursor_stride); guac_protocol_send_png(socket, GUAC_COMP_SRC, cursor, 0, 0, graphic); cairo_surface_destroy(graphic); @@ -82,8 +82,8 @@ void guac_vnc_set_pointer_cursor(guac_client* client) { /* Set cursor */ guac_protocol_send_cursor(socket, 0, 0, cursor, 0, 0, - guac_vnc_pointer_cursor_width, - guac_vnc_pointer_cursor_height); + guac_common_pointer_cursor_width, + guac_common_pointer_cursor_height); /* Free buffer */ guac_client_free_buffer(client, cursor); diff --git a/src/protocols/vnc/pointer_cursor.h b/src/common/guac_pointer_cursor.h similarity index 80% rename from src/protocols/vnc/pointer_cursor.h rename to src/common/guac_pointer_cursor.h index 040c182a..5c3dcd0d 100644 --- a/src/protocols/vnc/pointer_cursor.h +++ b/src/common/guac_pointer_cursor.h @@ -21,8 +21,8 @@ */ -#ifndef _GUAC_VNC_POINTER_CURSOR_H -#define _GUAC_VNC_POINTER_CURSOR_H +#ifndef _GUAC_COMMON_POINTER_CURSOR_H +#define _GUAC_COMMON_POINTER_CURSOR_H #include "config.h" @@ -32,33 +32,33 @@ /** * Width of the embedded mouse cursor graphic. */ -extern const int guac_vnc_pointer_cursor_width; +extern const int guac_common_pointer_cursor_width; /** * Height of the embedded mouse cursor graphic. */ -extern const int guac_vnc_pointer_cursor_height; +extern const int guac_common_pointer_cursor_height; /** * Number of bytes in each row of the embedded mouse cursor graphic. */ -extern const int guac_vnc_pointer_cursor_stride; +extern const int guac_common_pointer_cursor_stride; /** * The Cairo grapic format of the mouse cursor graphic. */ -extern const cairo_format_t guac_vnc_pointer_cursor_format; +extern const cairo_format_t guac_common_pointer_cursor_format; /** * Embedded mouse cursor graphic. */ -extern unsigned char guac_vnc_pointer_cursor[]; +extern unsigned char guac_common_pointer_cursor[]; /** * 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_pointer_cursor(guac_client* client); +void guac_common_set_pointer_cursor(guac_client* client); #endif diff --git a/src/protocols/vnc/Makefile.am b/src/protocols/vnc/Makefile.am index 68ff953d..648d39aa 100644 --- a/src/protocols/vnc/Makefile.am +++ b/src/protocols/vnc/Makefile.am @@ -23,24 +23,22 @@ AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 -AM_CFLAGS = -Werror -Wall -pedantic -Iinclude @LIBGUAC_INCLUDE@ +AM_CFLAGS = -Werror -Wall -pedantic -Iinclude \ + @COMMON_INCLUDE@ \ + @LIBGUAC_INCLUDE@ lib_LTLIBRARIES = libguac-client-vnc.la libguac_client_vnc_la_SOURCES = \ client.c \ convert.c \ - dot_cursor.c \ guac_handlers.c \ - pointer_cursor.c \ vnc_handlers.c noinst_HEADERS = \ client.h \ convert.h \ - dot_cursor.h \ guac_handlers.h \ - pointer_cursor.h \ vnc_handlers.h # Optional PulseAudio support @@ -49,6 +47,10 @@ libguac_client_vnc_la_SOURCES += pulse.c noinst_HEADERS += pulse.h endif -libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 @VNC_LIBS@ @CAIRO_LIBS@ @PULSE_LIBS@ +libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 \ + @CAIRO_LIBS@ \ + @PULSE_LIBS@ \ + @VNC_LIBS@ + libguac_client_vnc_la_LIBADD = @LIBGUAC_LTLIB@ diff --git a/src/protocols/vnc/client.c b/src/protocols/vnc/client.c index 4afb8738..5d15b51b 100644 --- a/src/protocols/vnc/client.c +++ b/src/protocols/vnc/client.c @@ -23,9 +23,9 @@ #include "config.h" #include "client.h" -#include "dot_cursor.h" +#include "guac_dot_cursor.h" #include "guac_handlers.h" -#include "pointer_cursor.h" +#include "guac_pointer_cursor.h" #include "vnc_handlers.h" #include @@ -356,11 +356,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* If not read-only but cursor is remote, set a dot cursor */ if (guac_client_data->remote_cursor) - guac_vnc_set_dot_cursor(client); + guac_common_set_dot_cursor(client); /* Otherwise, set pointer until explicitly requested otherwise */ else - guac_vnc_set_pointer_cursor(client); + guac_common_set_pointer_cursor(client); }