diff --git a/src/common/guac_surface.c b/src/common/guac_surface.c index d2c6a435..3ef36666 100644 --- a/src/common/guac_surface.c +++ b/src/common/guac_surface.c @@ -25,6 +25,7 @@ #include "guac_surface.h" #include +#include #include #include #include @@ -660,12 +661,14 @@ static void __guac_common_surface_transfer(guac_common_surface* src, int* sx, in } -guac_common_surface* guac_common_surface_alloc(guac_socket* socket, const guac_layer* layer, int w, int h) { +guac_common_surface* guac_common_surface_alloc(guac_client* client, + guac_socket* socket, const guac_layer* layer, int w, int h) { /* Init surface */ guac_common_surface* surface = malloc(sizeof(guac_common_surface)); - surface->layer = layer; + surface->client = client; surface->socket = socket; + surface->layer = layer; surface->width = w; surface->height = h; surface->dirty = 0; diff --git a/src/common/guac_surface.h b/src/common/guac_surface.h index b5ba89f2..cacfc2d9 100644 --- a/src/common/guac_surface.h +++ b/src/common/guac_surface.h @@ -27,6 +27,7 @@ #include "guac_rect.h" #include +#include #include #include #include @@ -65,6 +66,11 @@ typedef struct guac_common_surface { */ const guac_layer* layer; + /** + * The client associated with this surface. + */ + guac_client* client; + /** * The socket to send instructions on when flushing. */ @@ -131,13 +137,26 @@ typedef struct guac_common_surface { /** * Allocates a new guac_common_surface, assigning it to the given layer. * - * @param socket The socket to send instructions on when flushing. - * @param layer The layer to associate with the new surface. - * @param w The width of the surface. - * @param h The height of the surface. - * @return A newly-allocated guac_common_surface. + * @param client + * The client associated with the given layer. + * + * @param socket + * The socket to send instructions on when flushing. + * + * @param layer + * The layer to associate with the new surface. + * + * @param w + * The width of the surface. + * + * @param h + * The height of the surface. + * + * @return + * A newly-allocated guac_common_surface. */ -guac_common_surface* guac_common_surface_alloc(guac_socket* socket, const guac_layer* layer, int w, int h); +guac_common_surface* guac_common_surface_alloc(guac_client* client, + guac_socket* socket, const guac_layer* layer, int w, int h); /** * Frees the given guac_common_surface. Beware that this will NOT free any diff --git a/src/protocols/rdp/client.c b/src/protocols/rdp/client.c index ab2c104f..ccd6776d 100644 --- a/src/protocols/rdp/client.c +++ b/src/protocols/rdp/client.c @@ -933,8 +933,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) { #endif /* Create default surface */ - guac_client_data->default_surface = guac_common_surface_alloc(client->socket, GUAC_DEFAULT_LAYER, - settings->width, settings->height); + guac_client_data->default_surface = guac_common_surface_alloc(client, + client->socket, GUAC_DEFAULT_LAYER, + settings->width, settings->height); guac_client_data->current_surface = guac_client_data->default_surface; /* Send connection name */ diff --git a/src/protocols/rdp/rdp_bitmap.c b/src/protocols/rdp/rdp_bitmap.c index a3211bf4..8de2fcc1 100644 --- a/src/protocols/rdp/rdp_bitmap.c +++ b/src/protocols/rdp/rdp_bitmap.c @@ -50,7 +50,8 @@ void guac_rdp_cache_bitmap(rdpContext* context, rdpBitmap* bitmap) { /* Allocate surface */ guac_layer* buffer = guac_client_alloc_buffer(client); - guac_common_surface* surface = guac_common_surface_alloc(socket, buffer, bitmap->width, bitmap->height); + guac_common_surface* surface = guac_common_surface_alloc(client, socket, + buffer, bitmap->width, bitmap->height); /* Cache image data if present */ if (bitmap->data != NULL) { diff --git a/src/protocols/vnc/client.c b/src/protocols/vnc/client.c index e40a62dc..201cdcd8 100644 --- a/src/protocols/vnc/client.c +++ b/src/protocols/vnc/client.c @@ -549,8 +549,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) { guac_protocol_send_name(client->socket, rfb_client->desktopName); /* Create default surface */ - guac_client_data->default_surface = guac_common_surface_alloc(client->socket, GUAC_DEFAULT_LAYER, - rfb_client->width, rfb_client->height); + guac_client_data->default_surface = guac_common_surface_alloc(client, + client->socket, GUAC_DEFAULT_LAYER, + rfb_client->width, rfb_client->height); return 0; } diff --git a/src/terminal/display.c b/src/terminal/display.c index c90c2882..5a3b40f5 100644 --- a/src/terminal/display.c +++ b/src/terminal/display.c @@ -276,8 +276,8 @@ guac_terminal_display* guac_terminal_display_alloc(guac_client* client, /* Create default surface */ display->display_layer = guac_client_alloc_layer(client); display->select_layer = guac_client_alloc_layer(client); - display->display_surface = guac_common_surface_alloc(client->socket, - display->display_layer, 0, 0); + display->display_surface = guac_common_surface_alloc(client, + client->socket, display->display_layer, 0, 0); /* Select layer is a child of the display layer */ guac_protocol_send_move(client->socket, display->select_layer,