GUAC-771: Ensure display surface is available during initial connection.

This commit is contained in:
Michael Jumper 2014-07-21 09:12:17 -07:00
parent c7a65d08cb
commit fd800e6dd7
7 changed files with 106 additions and 36 deletions

View File

@ -307,6 +307,7 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) {
free(pointer); free(pointer);
/* Set up GDI */ /* Set up GDI */
instance->update->DesktopResize = guac_rdp_gdi_desktop_resize;
instance->update->EndPaint = guac_rdp_gdi_end_paint; instance->update->EndPaint = guac_rdp_gdi_end_paint;
instance->update->Palette = guac_rdp_gdi_palette_update; instance->update->Palette = guac_rdp_gdi_palette_update;
instance->update->SetBounds = guac_rdp_gdi_set_bounds; instance->update->SetBounds = guac_rdp_gdi_set_bounds;
@ -696,6 +697,17 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* Load keymap into client */ /* Load keymap into client */
__guac_rdp_client_load_keymap(client, settings->server_layout); __guac_rdp_client_load_keymap(client, settings->server_layout);
/* Create default surface */
guac_client_data->default_surface = guac_common_surface_alloc(client->socket, GUAC_DEFAULT_LAYER,
settings->width, settings->height);
guac_client_data->current_surface = guac_client_data->default_surface;
/* Send connection name */
guac_protocol_send_name(client->socket, settings->hostname);
/* Set default pointer */
guac_common_set_pointer_cursor(client);
/* Push desired settings to FreeRDP */ /* Push desired settings to FreeRDP */
guac_rdp_push_settings(settings, rdp_inst); guac_rdp_push_settings(settings, rdp_inst);
@ -705,20 +717,6 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
return 1; return 1;
} }
/* Pull actual settings back from FreeRDP */
guac_rdp_pull_settings(rdp_inst, settings);
/* Send connection name */
guac_protocol_send_name(client->socket, settings->hostname);
/* Create default surface */
guac_client_data->default_surface = guac_common_surface_alloc(client->socket, GUAC_DEFAULT_LAYER,
settings->width, settings->height);
guac_client_data->current_surface = guac_client_data->default_surface;
/* Set default pointer */
guac_common_set_pointer_cursor(client);
/* Success */ /* Success */
return 0; return 0;

View File

@ -79,14 +79,10 @@ void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) {
/* Convert image data if present */ /* Convert image data if present */
if (bitmap->data != NULL) { if (bitmap->data != NULL) {
/* Get client data */
guac_client* client = ((rdp_freerdp_context*) context)->client;
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
/* Convert image data to 32-bit RGB */ /* Convert image data to 32-bit RGB */
unsigned char* image_buffer = freerdp_image_convert(bitmap->data, NULL, unsigned char* image_buffer = freerdp_image_convert(bitmap->data, NULL,
bitmap->width, bitmap->height, bitmap->width, bitmap->height,
client_data->settings.color_depth, guac_rdp_get_depth(context->instance),
32, ((rdp_freerdp_context*) context)->clrconv); 32, ((rdp_freerdp_context*) context)->clrconv);
/* Free existing image, if any */ /* Free existing image, if any */

View File

@ -372,3 +372,17 @@ void guac_rdp_gdi_end_paint(rdpContext* context) {
/* IGNORE */ /* IGNORE */
} }
void guac_rdp_gdi_desktop_resize(rdpContext* context) {
guac_client* client = ((rdp_freerdp_context*) context)->client;
rdp_guac_client_data* data = (rdp_guac_client_data*) client->data;
guac_common_surface_resize(data->default_surface,
guac_rdp_get_width(context->instance),
guac_rdp_get_height(context->instance));
guac_common_surface_reset_clip(data->default_surface);
}

View File

@ -29,16 +29,59 @@
#include <freerdp/freerdp.h> #include <freerdp/freerdp.h>
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
guac_composite_mode guac_rdp_rop3_transfer_function(guac_client* client, /**
int rop3); * Translates a standard RDP ROP3 value into a guac_composite_mode.
*/
guac_composite_mode guac_rdp_rop3_transfer_function(guac_client* client, int rop3);
/**
* Handler for RDP DSTBLT update.
*/
void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt); void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt);
/**
* Handler for RDP PATBLT update.
*/
void guac_rdp_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt); void guac_rdp_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt);
/**
* Handler for RDP SCRBLT update.
*/
void guac_rdp_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt); void guac_rdp_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt);
/**
* Handler for RDP MEMBLT update.
*/
void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt); void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt);
/**
* Handler for RDP OPAQUE_RECT update.
*/
void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect); void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect);
/**
* Handler called when the remote color palette is changing.
*/
void guac_rdp_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette); void guac_rdp_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette);
/**
* Handler called prior to calling the handlers for specific updates when
* those updatese are clipped by a bounding rectangle.
*/
void guac_rdp_gdi_set_bounds(rdpContext* context, rdpBounds* bounds); void guac_rdp_gdi_set_bounds(rdpContext* context, rdpBounds* bounds);
/**
* Handler called when a paint operation is complete. We don't actually
* use this, but FreeRDP requires it.
*/
void guac_rdp_gdi_end_paint(rdpContext* context); void guac_rdp_gdi_end_paint(rdpContext* context);
/**
* Handler called when the desktop dimensions change, either from a
* true desktop resize event received by the RDP client, or due to
* a revised size given by the server during initial connection
* negotiation.
*/
void guac_rdp_gdi_desktop_resize(rdpContext* context);
#endif #endif

View File

@ -136,7 +136,7 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
/* Convert background color */ /* Convert background color */
bgcolor = freerdp_color_convert_var(bgcolor, bgcolor = freerdp_color_convert_var(bgcolor,
guac_client_data->settings.color_depth, 32, guac_rdp_get_depth(context->instance), 32,
((rdp_freerdp_context*) context)->clrconv); ((rdp_freerdp_context*) context)->clrconv);
guac_common_surface_rect(guac_client_data->current_surface, x, y, width, height, guac_common_surface_rect(guac_client_data->current_surface, x, y, width, height,
@ -148,7 +148,7 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
/* Convert foreground color */ /* Convert foreground color */
guac_client_data->glyph_color = freerdp_color_convert_var(fgcolor, guac_client_data->glyph_color = freerdp_color_convert_var(fgcolor,
guac_client_data->settings.color_depth, 32, ((rdp_freerdp_context*) context)->clrconv); guac_rdp_get_depth(context->instance), 32, ((rdp_freerdp_context*) context)->clrconv);
} }

View File

@ -34,20 +34,28 @@
#include <stddef.h> #include <stddef.h>
void guac_rdp_pull_settings(freerdp* rdp, guac_rdp_settings* guac_settings) { int guac_rdp_get_width(freerdp* rdp) {
rdpSettings* rdp_settings = rdp->settings;
#ifdef LEGACY_RDPSETTINGS #ifdef LEGACY_RDPSETTINGS
guac_settings->color_depth = rdp_settings->color_depth; return rdp->settings->width;
guac_settings->width = rdp_settings->width;
guac_settings->height = rdp_settings->height;
#else #else
guac_settings->color_depth = rdp_settings->ColorDepth; return rdp->settings->DesktopWidth;
guac_settings->width = rdp_settings->DesktopWidth;
guac_settings->height = rdp_settings->DesktopHeight;
#endif #endif
}
int guac_rdp_get_height(freerdp* rdp) {
#ifdef LEGACY_RDPSETTINGS
return rdp->settings->height;
#else
return rdp->settings->DesktopHeight;
#endif
}
int guac_rdp_get_depth(freerdp* rdp) {
#ifdef LEGACY_RDPSETTINGS
return rdp->settings->color_depth;
#else
return rdp->settings->ColorDepth;
#endif
} }
void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) { void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) {
@ -202,6 +210,7 @@ void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) {
rdp_settings->fast_path_input = FALSE; rdp_settings->fast_path_input = FALSE;
rdp_settings->fast_path_output = FALSE; rdp_settings->fast_path_output = FALSE;
#endif #endif
rdp_settings->desktop_resize = TRUE;
rdp_settings->order_support[NEG_DSTBLT_INDEX] = TRUE; rdp_settings->order_support[NEG_DSTBLT_INDEX] = TRUE;
rdp_settings->order_support[NEG_PATBLT_INDEX] = FALSE; /* PATBLT not yet supported */ rdp_settings->order_support[NEG_PATBLT_INDEX] = FALSE; /* PATBLT not yet supported */
rdp_settings->order_support[NEG_SCRBLT_INDEX] = TRUE; rdp_settings->order_support[NEG_SCRBLT_INDEX] = TRUE;
@ -234,6 +243,7 @@ void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) {
rdp_settings->FastPathInput = FALSE; rdp_settings->FastPathInput = FALSE;
rdp_settings->FastPathOutput = FALSE; rdp_settings->FastPathOutput = FALSE;
#endif #endif
rdp_settings->DesktopResize = TRUE;
rdp_settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE; rdp_settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE;
rdp_settings->OrderSupport[NEG_PATBLT_INDEX] = FALSE; /* PATBLT not yet supported */ rdp_settings->OrderSupport[NEG_PATBLT_INDEX] = FALSE; /* PATBLT not yet supported */
rdp_settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE; rdp_settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;

View File

@ -209,10 +209,19 @@ typedef struct guac_rdp_settings {
void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp); void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp);
/** /**
* Pull all settings from the given freerdp instance into the client * Returns the width of the RDP session display.
* stored settings.
*/ */
void guac_rdp_pull_settings(freerdp* rdp, guac_rdp_settings* guac_settings); int guac_rdp_get_width(freerdp* rdp);
/**
* Returns the height of the RDP session display.
*/
int guac_rdp_get_height(freerdp* rdp);
/**
* Returns the depth of the RDP session display.
*/
int guac_rdp_get_depth(freerdp* rdp);
#endif #endif