Skip to content

Commit

Permalink
GUACAMOLE-288: Add parameter to limit the usage of multiple monitors.
Browse files Browse the repository at this point in the history
  • Loading branch information
corentin-soriano committed Oct 29, 2024
1 parent 4d1fe5c commit 90d0ee6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/protocols/rdp/channels/disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ void guac_rdp_disp_update_size(guac_rdp_disp* disp,
int height = disp->requested_height;
int monitors_count = disp->requested_monitors;

/* Prevent opening too many monitors than allowed */
if (settings->max_secondary_monitors + 1 < monitors_count)
monitors_count = settings->max_secondary_monitors + 1;

/* At least one monitor is required */
if (monitors_count < 1)
monitors_count = 1;

/* Do not update size if no requests have been received */
if (width == 0 || height == 0)
return;
Expand Down
12 changes: 12 additions & 0 deletions src/protocols/rdp/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <guacamole/mem.h>
#include <guacamole/recording.h>
#include <guacamole/rwlock.h>
#include <guacamole/string.h>

#include <dirent.h>
#include <errno.h>
Expand Down Expand Up @@ -133,6 +134,17 @@ static int guac_rdp_join_pending_handler(guac_client* client) {
/* Synchronize with current display */
if (rdp_client->display != NULL) {
guac_display_dup(rdp_client->display, broadcast_socket);

/* Get max secondary monitors */
char* max_monitors = guac_mem_alloc(12);
guac_itoa(max_monitors,
(unsigned int) rdp_client->settings->max_secondary_monitors);

/* Send current max allowed secondary monitors */
guac_client_stream_argv(client, broadcast_socket, "text/plain",
"secondary-monitors", max_monitors);
guac_mem_free(max_monitors);

guac_socket_flush(broadcast_socket);
}

Expand Down
12 changes: 12 additions & 0 deletions src/protocols/rdp/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
"create-recording-path",
"recording-write-existing",
"resize-method",
"secondary-monitors",
"enable-audio-input",
"enable-touch",
"read-only",
Expand Down Expand Up @@ -598,6 +599,12 @@ enum RDP_ARGS_IDX {
*/
IDX_RESIZE_METHOD,

/**
* The maximum allowed count of secondary monitors.
* 0 to disable.
*/
IDX_SECONDARY_MONITORS,

/**
* "true" if audio input (microphone) should be enabled for the RDP
* connection, "false" or blank otherwise.
Expand Down Expand Up @@ -1234,6 +1241,11 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
settings->resize_method = GUAC_RESIZE_NONE;
}

/* Maximum secondary monitors (default 0 = disabled) */
settings->max_secondary_monitors =
guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv,
IDX_SECONDARY_MONITORS, 0);

/* RDP Graphics Pipeline enable/disable */
settings->enable_gfx =
!guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,
Expand Down
5 changes: 5 additions & 0 deletions src/protocols/rdp/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ typedef struct guac_rdp_settings {
*/
guac_rdp_resize_method resize_method;

/**
* The maximum allowed count of secondary monitors.
*/
int max_secondary_monitors;

/**
* Whether audio input (microphone) is enabled.
*/
Expand Down

0 comments on commit 90d0ee6

Please sign in to comment.