Skip to content

Commit

Permalink
GUACAMOLE-1196: Remove unnecessary display size checking for VNC.
Browse files Browse the repository at this point in the history
  • Loading branch information
necouchman committed May 25, 2024
1 parent 12c98e3 commit 137d316
Showing 1 changed file with 5 additions and 52 deletions.
57 changes: 5 additions & 52 deletions src/protocols/vnc/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,48 +175,6 @@ 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) {

Expand All @@ -226,16 +184,11 @@ 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. */
guac_vnc_client* vnc_client = (guac_vnc_client*) display->client->data;
pthread_mutex_lock(&(vnc_client->message_lock));
SendExtDesktopSize(rfb_client, width, height);
pthread_mutex_unlock(&(vnc_client->message_lock));

}

Expand Down

0 comments on commit 137d316

Please sign in to comment.