GUAC-865: Initial support for display update.

This commit is contained in:
Michael Jumper 2014-11-21 13:30:24 -08:00
parent fdc21d3184
commit a0e1e5f0c6
8 changed files with 206 additions and 1 deletions

View File

@ -371,6 +371,7 @@ if test "x$with_rdp" != "xno"
then
have_winpr=yes
have_freerdp=yes
have_disp=yes
legacy_freerdp_extensions=no
rdpsettings_interface=unknown
rdpsettings_audioplayback=yes
@ -479,7 +480,8 @@ if test "x${have_freerdp}" = "xyes"
then
AC_CHECK_HEADERS([freerdp/client/disp.h],
[AC_DEFINE([HAVE_FREERDP_DISPLAY_UPDATE_SUPPORT],,
[Whether FreeRDP supports the display update channel])],,
[Whether FreeRDP supports the display update channel])],
have_disp=no,
[#include <winpr/wtypes.h>
#include <winpr/collections.h>])
fi
@ -747,6 +749,7 @@ then
fi
AM_CONDITIONAL([LEGACY_FREERDP_EXTENSIONS], [test "x${legacy_freerdp_extensions}" = "xyes"])
AM_CONDITIONAL([ENABLE_DISPLAY_UPDATE], [test "x${have_disp}" = "xyes"])
AM_CONDITIONAL([ENABLE_WINPR], [test "x${have_winpr}" = "xyes"])
AM_CONDITIONAL([ENABLE_RDP], [test "x${have_freerdp}" = "xyes"])

View File

@ -106,6 +106,12 @@ guacsnd_sources += compat/winpr-stream.c
guacdr_sources += compat/winpr-stream.c
endif
# Add display update channel support, if supported by FreeRDP
if ENABLE_DISPLAY_UPDATE
noinst_HEADERS += rdp_disp.h
libguac_client_rdp_la_SOURCES += rdp_disp.c
endif
libguac_client_rdp_la_LDFLAGS = -version-info 0:0:0 @RDP_LIBS@ @PTHREAD_LIBS@ @CAIRO_LIBS@
guacsvc_ldflags = -module -avoid-version -shared @RDP_LIBS@ @PTHREAD_LIBS@
guacsnd_ldflags = -module -avoid-version -shared @RDP_LIBS@ @PTHREAD_LIBS@

View File

@ -34,6 +34,10 @@
#include "rdp_stream.h"
#include "rdp_svc.h"
#ifdef HAVE_FREERDP_DISPLAY_UPDATE_SUPPORT
#include "rdp_disp.h"
#endif
#include <freerdp/cache/bitmap.h>
#include <freerdp/cache/brush.h>
#include <freerdp/cache/glyph.h>
@ -159,6 +163,18 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) {
freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0);
#endif
/* Load virtual channel management plugin */
if (freerdp_channels_load_plugin(channels, instance->settings,
"drdynvc", instance->settings))
guac_client_log(client, GUAC_LOG_WARNING,
"Failed to load drdynvc plugin.");
#ifdef HAVE_FREERDP_DISPLAY_UPDATE_SUPPORT
/* Init display update plugin */
guac_client_data->disp = NULL;
guac_rdp_disp_load_plugin(instance->context);
#endif
/* Load clipboard plugin */
if (freerdp_channels_load_plugin(channels, instance->settings,
"cliprdr", NULL))
@ -357,6 +373,7 @@ BOOL rdp_freerdp_post_connect(freerdp* instance) {
client->handle_messages = rdp_guac_client_handle_messages;
client->mouse_handler = rdp_guac_client_mouse_handler;
client->key_handler = rdp_guac_client_key_handler;
client->size_handler = rdp_guac_client_size_handler;
/* Stream handlers */
client->clipboard_handler = guac_rdp_clipboard_handler;

View File

@ -38,6 +38,10 @@
#include <guacamole/audio.h>
#include <guacamole/client.h>
#ifdef HAVE_FREERDP_CLIENT_DISP_H
#include <freerdp/client/disp.h>
#endif
#include <pthread.h>
#include <stdint.h>
@ -153,6 +157,13 @@ typedef struct rdp_guac_client_data {
*/
guac_rdp_fs* filesystem;
#ifdef HAVE_FREERDP_DISPLAY_UPDATE_SUPPORT
/**
* Display control interface.
*/
DispClientContext* disp;
#endif
/**
* List of all available static virtual channels.
*/

View File

@ -44,6 +44,10 @@
#include <guacamole/protocol.h>
#include <guacamole/timestamp.h>
#ifdef HAVE_FREERDP_DISPLAY_UPDATE_SUPPORT
#include "rdp_disp.h"
#endif
#ifdef HAVE_FREERDP_CLIENT_CLIPRDR_H
#include <freerdp/client/cliprdr.h>
#else
@ -456,3 +460,19 @@ int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
}
int rdp_guac_client_size_handler(guac_client* client, int width, int height) {
#ifdef HAVE_FREERDP_DISPLAY_UPDATE_SUPPORT
rdp_guac_client_data* guac_client_data =
(rdp_guac_client_data*) client->data;
freerdp* rdp_inst = guac_client_data->rdp_inst;
/* Send display update */
guac_rdp_disp_send_size(rdp_inst->context, width, height);
#endif
return 0;
}

View File

@ -32,6 +32,7 @@ int rdp_guac_client_free_handler(guac_client* client);
int rdp_guac_client_handle_messages(guac_client* client);
int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask);
int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed);
int rdp_guac_client_size_handler(guac_client* client, int width, int height);
#endif

View File

@ -0,0 +1,105 @@
/*
* Copyright (C) 2013 Glyptodon LLC
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/
#include "client.h"
#include <freerdp/freerdp.h>
#include <freerdp/client/disp.h>
#include <guacamole/client.h>
/**
* Called whenever a channel connects. If that channel happens to be the
* display update channel, a reference to that channel will be stored within
* the guac_client data.
*/
static void guac_rdp_disp_channel_connected(rdpContext* context,
ChannelConnectedEventArgs* e) {
/* Store reference to the display update plugin once it's connected */
if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) {
DispClientContext* disp = (DispClientContext*) e->pInterface;
guac_client* client = ((rdp_freerdp_context*) context)->client;
rdp_guac_client_data* guac_client_data =
(rdp_guac_client_data*) client->data;
guac_client_data->disp = disp;
guac_client_log(client, GUAC_LOG_DEBUG,
"Display update channel connected.");
}
}
void guac_rdp_disp_load_plugin(rdpContext* context) {
/* Subscribe to and handle channel connected events */
PubSub_SubscribeChannelConnected(context->pubSub,
(pChannelConnectedEventHandler) guac_rdp_disp_channel_connected);
context->settings->SupportDisplayControl = TRUE;
/* Add "disp" channel */
ADDIN_ARGV* args = malloc(sizeof(ADDIN_ARGV));
args->argc = 1;
args->argv = malloc(sizeof(char**) * 1);
args->argv[0] = strdup("disp");
freerdp_dynamic_channel_collection_add(context->settings, args);
}
void guac_rdp_disp_send_size(rdpContext* context, int width, int height) {
guac_client* client = ((rdp_freerdp_context*) context)->client;
rdp_guac_client_data* guac_client_data =
(rdp_guac_client_data*) client->data;
/* Send display update notification if display channel is connected */
if (guac_client_data->disp != NULL) {
guac_client_log(client, GUAC_LOG_DEBUG,
"Resizing remote display to %ix%i\n",
width, height);
DISPLAY_CONTROL_MONITOR_LAYOUT monitors[1] = {{
.Flags = 0x1, /* DISPLAYCONTROL_MONITOR_PRIMARY */
.Left = 0,
.Top = 0,
.Width = width,
.Height = height,
.PhysicalWidth = 0,
.PhysicalHeight = 0,
.Orientation = 0,
.DesktopScaleFactor = 0,
.DeviceScaleFactor = 0
}};
guac_client_data->disp->SendMonitorLayout(guac_client_data->disp, 1,
monitors);
}
}

View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2013 Glyptodon LLC
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/
#ifndef GUAC_RDP_DISP_H
#define GUAC_RDP_DISP_H
#include <freerdp/freerdp.h>
/**
* Loads the "disp" plugin for FreeRDP. If successfully loaded, it will be
* stored within the guac_client data.
*/
void guac_rdp_disp_load_plugin(rdpContext* context);
/**
* Sends a display update message to the RDP server, notifying that the
* monitor layout has changed to a single monitor of the given width and
* height (in pixels).
*/
void guac_rdp_disp_send_size(rdpContext* context, int width, int height);
#endif