diff --git a/src/protocols/vnc/client.c b/src/protocols/vnc/client.c index b53fc00871..54d222a000 100644 --- a/src/protocols/vnc/client.c +++ b/src/protocols/vnc/client.c @@ -108,7 +108,6 @@ int guac_client_init(guac_client* client) { #ifdef ENABLE_VNC_DESKTOP_SIZE guac_client_log(client, GUAC_LOG_DEBUG, "Support for desktop sizing enabled."); - vnc_client->vnc_display = guac_vnc_display_update_alloc(client); #else guac_client_log(client, GUAC_LOG_WARNING, "VNC client does not support desktop sizing."); #endif @@ -222,10 +221,6 @@ int guac_vnc_client_free_handler(guac_client* client) { /* Clean up the message lock. */ pthread_mutex_destroy(&(vnc_client->message_lock)); -#ifdef ENABLE_VNC_DESKTOP_SIZE - guac_vnc_display_update_free(vnc_client->vnc_display); -#endif - /* Free generic data struct */ guac_mem_free(client->data); diff --git a/src/protocols/vnc/display.c b/src/protocols/vnc/display.c index b244bad3ec..2f022bb287 100644 --- a/src/protocols/vnc/display.c +++ b/src/protocols/vnc/display.c @@ -157,68 +157,11 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, in #ifdef ENABLE_VNC_DESKTOP_SIZE -guac_vnc_display* guac_vnc_display_update_alloc(guac_client* client) { +void guac_vnc_display_set_size(rfbClient* client, int width, int height) { - guac_vnc_display* display = guac_mem_alloc(sizeof(guac_vnc_display)); - display->client = client; - - /* No requests have been made */ - display->last_request = guac_timestamp_current(); - display->requested_width = 0; - display->requested_height = 0; - - return display; - -} - -void guac_vnc_display_update_free(guac_vnc_display* display) { - guac_mem_free(display); -} - -/** - * This function does the actual work of updating the display size if adequate - * time has passed since the last update and the size is actually different. -* - * @param display - * The data structure that contains information used for determing if and - * when display updates should be allowed. - * - * @param rfb_client - * A pointer to the VNC (RFB) client. - */ -static void guac_vnc_display_update_size(guac_vnc_display* display, - rfbClient* rfb_client) { - - int width = display->requested_width; - int height = display->requested_height; - - /* Do not update size if no requests have been received */ - if (width == 0 || height == 0) - return; - - guac_timestamp now = guac_timestamp_current(); - - /* Limit display update frequency */ - if (now - display->last_request <= GUAC_COMMON_DISPLAY_UPDATE_INTERVAL) - return; - - /* Do NOT send requests unless the size will change */ - if (rfb_client != NULL - && width == rfb_client->screen.width - && height == rfb_client->screen.height) - return; - - /* Send the display size update. */ - guac_vnc_client* vnc_client = (guac_vnc_client*) display->client->data; - pthread_mutex_lock(&(vnc_client->message_lock)); - SendExtDesktopSize(rfb_client, width, height); - display->last_request = now; - pthread_mutex_unlock(&(vnc_client->message_lock)); - -} - -void guac_vnc_display_set_size(guac_vnc_display* display, - rfbClient* rfb_client, int width, int height) { + /* Get the VNC client */ + guac_client* gc = rfbClientGetClientData(client, GUAC_VNC_CLIENT_KEY); + guac_vnc_client* vnc_client = (guac_vnc_client*) gc->data; /* Fit width within bounds, adjusting height to maintain aspect ratio */ guac_common_display_fit(&width, &height); @@ -226,20 +169,14 @@ void guac_vnc_display_set_size(guac_vnc_display* display, /* Fit height within bounds, adjusting width to maintain aspect ratio */ guac_common_display_fit(&height, &width); - /* Width must be even */ - if (width % 2 == 1) - width -= 1; - - /* Store deferred size */ - display->requested_width = width; - display->requested_height = height; - - /* Send display update notification if possible */ - guac_vnc_display_update_size(display, rfb_client); + /* Send the display size update. */ + pthread_mutex_lock(&(vnc_client->message_lock)); + SendExtDesktopSize(client, width, height); + pthread_mutex_unlock(&(vnc_client->message_lock)); } -#endif +#endif // ENABLE_VNC_DESKTOP_SIZE void guac_vnc_set_pixel_format(rfbClient* client, int color_depth) { client->format.trueColour = 1; diff --git a/src/protocols/vnc/display.h b/src/protocols/vnc/display.h index 7221167fe2..d050f45b2a 100644 --- a/src/protocols/vnc/display.h +++ b/src/protocols/vnc/display.h @@ -25,34 +25,6 @@ #include #include -/** - * Display size update module for VNC. - */ -typedef struct guac_vnc_display { - - /** - * The guac_client instance handling the relevant VNC connection. - */ - guac_client* client; - - /** - * The timestamp of the last display update request, or 0 if no request - * has been sent yet. - */ - guac_timestamp last_request; - - /** - * The last requested screen width, in pixels. - */ - int requested_width; - - /** - * The last requested screen height, in pixels. - */ - int requested_height; - -} guac_vnc_display; - /** * Callback invoked by libVNCServer when it receives a new binary image data * from the VNC server. The image itself will be stored in the designated sub- @@ -114,42 +86,13 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, #ifdef ENABLE_VNC_DESKTOP_SIZE -/** - * Allocates a new VNC display update module, which will keep track of the data - * needed to handle display updates. - * - * @param client - * The guac_client instance handling the relevant VNC connection. - * - * @return - * A newly-allocated VNC display update module. - */ -guac_vnc_display* guac_vnc_display_update_alloc(guac_client* client); - -/** - * Frees the resources associated with the data structure that keeps track of - * items related to VNC display updates. Only resources specific to Guacamole - * are freed. Resources that are part of the rfbClient will be freed separately. - * If no resources are currently allocated for Display Update support, this - * function has no effect. - * - * @param display - * The display update module to free. - */ -void guac_vnc_display_update_free(guac_vnc_display* display); - /** * Attempts to set the display size of the remote server to the size requested * by the client, usually as part of a client (browser) resize, if supported by * both the VNC client and the remote server. * * @param display - * The VNC display update object that tracks information related to display - * update requests. - * - * @param rfb_client - * The data structure containing the VNC client that is used by this - * connection. + * The VNC client to which the display size update should be sent. * * @param width * The width that is being requested, in pixels. @@ -157,10 +100,9 @@ void guac_vnc_display_update_free(guac_vnc_display* display); * @param height * The height that is being requested, in pixels. */ -void guac_vnc_display_set_size(guac_vnc_display* display, rfbClient* rfb_client, - int width, int height); +void guac_vnc_display_set_size(rfbClient* client, int width, int height); -#endif +#endif // ENABLE_VNC_DESKTOP_SIZE /** * Sets the pixel format to request of the VNC server. The request will be made diff --git a/src/protocols/vnc/input.c b/src/protocols/vnc/input.c index 47f896f6ac..c638fe7c75 100644 --- a/src/protocols/vnc/input.c +++ b/src/protocols/vnc/input.c @@ -69,11 +69,11 @@ int guac_vnc_user_key_handler(guac_user* user, int keysym, int pressed) { int guac_vnc_user_size_handler(guac_user* user, int width, int height) { + /* Get the Guacamole VNC client */ guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data; - rfbClient* rfb_client = vnc_client->rfb_client; /* Send display update */ - guac_vnc_display_set_size(vnc_client->vnc_display, rfb_client, width, height); + guac_vnc_display_set_size(vnc_client->rfb_client, width, height); return 0; diff --git a/src/protocols/vnc/vnc.h b/src/protocols/vnc/vnc.h index 4473180516..49477304bd 100644 --- a/src/protocols/vnc/vnc.h +++ b/src/protocols/vnc/vnc.h @@ -141,11 +141,6 @@ typedef struct guac_vnc_client { */ guac_iconv_write* clipboard_writer; - /** - * VNC display update module. - */ - guac_vnc_display* vnc_display; - } guac_vnc_client; /**