Skip to content

Commit 62c8b1e

Browse files
GUACAMOLE-288: Add parameter to limit the usage of multiple monitors.
1 parent b3c1351 commit 62c8b1e

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/protocols/rdp/channels/disp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ void guac_rdp_disp_update_size(guac_rdp_disp* disp,
195195
int height = disp->requested_height;
196196
int monitors_count = disp->requested_monitors;
197197

198+
/* Prevent opening too many monitors than allowed */
199+
if (settings->max_secondary_monitors + 1 < monitors_count)
200+
monitors_count = settings->max_secondary_monitors + 1;
201+
202+
/* At least one monitor is required */
203+
if (monitors_count < 1)
204+
monitors_count = 1;
205+
198206
/* Do not update size if no requests have been received */
199207
if (width == 0 || height == 0)
200208
return;

src/protocols/rdp/client.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <guacamole/mem.h>
4343
#include <guacamole/recording.h>
4444
#include <guacamole/rwlock.h>
45+
#include <guacamole/string.h>
4546

4647
#include <dirent.h>
4748
#include <errno.h>
@@ -130,6 +131,16 @@ static int guac_rdp_join_pending_handler(guac_client* client) {
130131
/* Bring user up to date with any registered static channels */
131132
guac_rdp_pipe_svc_send_pipes(client, broadcast_socket);
132133

134+
/* Get max secondary monitors */
135+
char* max_monitors = guac_mem_alloc(12);
136+
guac_itoa(max_monitors,
137+
(unsigned int) rdp_client->settings->max_secondary_monitors);
138+
139+
/* Send current max allowed secondary monitors */
140+
guac_client_stream_argv(client, broadcast_socket, "text/plain",
141+
"secondary-monitors", max_monitors);
142+
guac_mem_free(max_monitors);
143+
133144
/* Synchronize with current display */
134145
if (rdp_client->display != NULL) {
135146
guac_display_dup(rdp_client->display, broadcast_socket);

src/protocols/rdp/settings.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
128128
"create-recording-path",
129129
"recording-write-existing",
130130
"resize-method",
131+
"secondary-monitors",
131132
"enable-audio-input",
132133
"enable-touch",
133134
"read-only",
@@ -598,6 +599,12 @@ enum RDP_ARGS_IDX {
598599
*/
599600
IDX_RESIZE_METHOD,
600601

602+
/**
603+
* The maximum allowed count of secondary monitors.
604+
* 0 to disable.
605+
*/
606+
IDX_SECONDARY_MONITORS,
607+
601608
/**
602609
* "true" if audio input (microphone) should be enabled for the RDP
603610
* connection, "false" or blank otherwise.
@@ -1234,6 +1241,11 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
12341241
settings->resize_method = GUAC_RESIZE_NONE;
12351242
}
12361243

1244+
/* Maximum secondary monitors (default 0 = disabled) */
1245+
settings->max_secondary_monitors =
1246+
guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv,
1247+
IDX_SECONDARY_MONITORS, 0);
1248+
12371249
/* RDP Graphics Pipeline enable/disable */
12381250
settings->enable_gfx =
12391251
!guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,

src/protocols/rdp/settings.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,11 @@ typedef struct guac_rdp_settings {
596596
*/
597597
guac_rdp_resize_method resize_method;
598598

599+
/**
600+
* The maximum allowed count of secondary monitors.
601+
*/
602+
int max_secondary_monitors;
603+
599604
/**
600605
* Whether audio input (microphone) is enabled.
601606
*/

0 commit comments

Comments
 (0)