From 69b45885bdbbdf94056ff11a69d8367af46f7082 Mon Sep 17 00:00:00 2001 From: Virtually Nick Date: Fri, 5 Apr 2024 17:21:06 -0400 Subject: [PATCH 1/3] GUACAMOLE-1760: Add guacd support for setting VNC compression and quality. --- src/protocols/vnc/settings.c | 24 ++++++++++++++++++++++++ src/protocols/vnc/settings.h | 10 ++++++++++ src/protocols/vnc/vnc.c | 7 +++++++ 3 files changed, 41 insertions(+) diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c index 083a6c63..aa411047 100644 --- a/src/protocols/vnc/settings.c +++ b/src/protocols/vnc/settings.c @@ -95,6 +95,8 @@ const char* GUAC_VNC_CLIENT_ARGS[] = { "wol-wait-time", "force-lossless", + "compress-level", + "quality-level", NULL }; @@ -389,6 +391,18 @@ enum VNC_ARGS_IDX { */ IDX_FORCE_LOSSLESS, + /** + * The level of compression, on a scale of 0 (no compression) to 9 (maximum + * compression), that the connection will be configured for. + */ + IDX_COMPRESS_LEVEL, + + /** + * The level of display quality, on a scale of 0 (worst quality) to 9 (best + * quality), that the connection will be configured for. + */ + IDX_QUALITY_LEVEL, + VNC_ARGS_COUNT }; @@ -453,6 +467,16 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user, guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv, IDX_FORCE_LOSSLESS, false); + /* Compression level */ + settings->compress_level = + guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_COMPRESS_LEVEL, -1); + + /* Display quality */ + settings->quality_level = + guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_QUALITY_LEVEL, -1); + #ifdef ENABLE_VNC_REPEATER /* Set repeater parameters if specified */ settings->dest_host = diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h index 38034341..7ecd3700 100644 --- a/src/protocols/vnc/settings.h +++ b/src/protocols/vnc/settings.h @@ -82,6 +82,16 @@ typedef struct guac_vnc_settings { */ bool lossless; + /** + * The level of compression to ask the VNC client library to perform. + */ + int compress_level; + + /** + * The quality level to ask the VNC client library to maintain. + */ + int quality_level; + #ifdef ENABLE_VNC_REPEATER /** * The VNC host to connect to, if using a repeater. diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index 9fd9156a..85e97a13 100644 --- a/src/protocols/vnc/vnc.c +++ b/src/protocols/vnc/vnc.c @@ -440,6 +440,13 @@ void* guac_vnc_client_thread(void* data) { * heuristics) */ guac_common_display_set_lossless(vnc_client->display, settings->lossless); + /* If compression and display quality have been configured, set those. */ + if (settings->compress_level >= 0 && settings->compress_level <= 9) + rfb_client->appData.compressLevel = settings->compress_level; + + if (settings->quality_level >= 0 && settings->quality_level <= 9) + rfb_client->appData.qualityLevel = settings->quality_level; + /* If not read-only, set an appropriate cursor */ if (settings->read_only == 0) { if (settings->remote_cursor) From 4ba0b0169af78c14ed7d70987146dfe240aec572 Mon Sep 17 00:00:00 2001 From: pourfar <48383524+pourfar@users.noreply.github.com> Date: Tue, 16 Apr 2024 13:14:08 +0330 Subject: [PATCH 2/3] GUACAMOLE-1940: Correct flag comparison in "guac_rwlock_acquire_write_lock" function --- src/libguac/rwlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libguac/rwlock.c b/src/libguac/rwlock.c index 22d041b2..1ed71766 100644 --- a/src/libguac/rwlock.c +++ b/src/libguac/rwlock.c @@ -179,7 +179,7 @@ int guac_rwlock_acquire_write_lock(guac_rwlock* reentrant_rwlock) { * write lock by another function without the caller knowing about it. This * shouldn't cause any issues, however. */ - if (key_value == GUAC_REENTRANT_LOCK_READ_LOCK) + if (flag == GUAC_REENTRANT_LOCK_READ_LOCK) pthread_rwlock_unlock(&(reentrant_rwlock->lock)); /* Acquire the write lock */ From 825d87f496d83e24f89fce856b34fa4dec0adcc7 Mon Sep 17 00:00:00 2001 From: corentin-soriano Date: Tue, 16 Apr 2024 12:43:32 +0200 Subject: [PATCH 3/3] GUACAMOLE-1944: Remove display margin at mouse position --- src/terminal/terminal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index 25a5b137..68b3ad27 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -1751,6 +1751,10 @@ int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed) { static int __guac_terminal_send_mouse(guac_terminal* term, guac_user* user, int x, int y, int mask) { + /* Remove display margin from mouse position without going below 0 */ + y = y >= term->display->margin ? y - term->display->margin : 0; + x = x >= term->display->margin ? x - term->display->margin : 0; + /* Ignore user input if terminal is not started */ if (!term->started) { guac_client_log(term->client, GUAC_LOG_DEBUG, "Ignoring user input "