@@ -44,9 +44,10 @@ guac_rdp_disp* guac_rdp_disp_alloc(guac_client* client) {
4444
4545 /* No requests have been made */
4646 disp -> last_request = guac_timestamp_current ();
47- disp -> requested_width = 0 ;
48- disp -> requested_height = 0 ;
49- disp -> reconnect_needed = 0 ;
47+ disp -> requested_width = 0 ;
48+ disp -> requested_height = 0 ;
49+ disp -> reconnect_needed = 0 ;
50+ disp -> requested_monitors = 1 ;
5051
5152 return disp ;
5253
@@ -88,7 +89,7 @@ static void guac_rdp_disp_channel_connected(rdpContext* context,
8889 /* Init module with current display size */
8990 guac_rdp_disp_set_size (guac_disp , rdp_client -> settings ,
9091 context -> instance , guac_rdp_get_width (context -> instance ),
91- guac_rdp_get_height (context -> instance ));
92+ guac_rdp_get_height (context -> instance ), 1 );
9293
9394 /* Store reference to the display update plugin once it's connected */
9495 DispClientContext * disp = (DispClientContext * ) args -> pInterface ;
@@ -180,6 +181,7 @@ void guac_rdp_disp_set_size(guac_rdp_disp* disp, guac_rdp_settings* settings,
180181 /* Store deferred size */
181182 disp -> requested_width = width ;
182183 disp -> requested_height = height ;
184+ disp -> requested_monitors = monitors ;
183185
184186 /* Send display update notification if possible */
185187 guac_rdp_disp_update_size (disp , settings , rdp_inst );
@@ -191,6 +193,7 @@ void guac_rdp_disp_update_size(guac_rdp_disp* disp,
191193
192194 int width = disp -> requested_width ;
193195 int height = disp -> requested_height ;
196+ int monitors_count = disp -> requested_monitors ;
194197
195198 /* Do not update size if no requests have been received */
196199 if (width == 0 || height == 0 )
@@ -204,7 +207,7 @@ void guac_rdp_disp_update_size(guac_rdp_disp* disp,
204207
205208 /* Do NOT send requests unless the size will change */
206209 if (rdp_inst != NULL
207- && width == guac_rdp_get_width (rdp_inst )
210+ && width * monitors_count == guac_rdp_get_width (rdp_inst )
208211 && height == guac_rdp_get_height (rdp_inst ))
209212 return ;
210213
@@ -221,32 +224,46 @@ void guac_rdp_disp_update_size(guac_rdp_disp* disp,
221224
222225 }
223226
224- else if (settings -> resize_method == GUAC_RESIZE_DISPLAY_UPDATE ) {
225- DISPLAY_CONTROL_MONITOR_LAYOUT monitors [1 ] = {{
226- .Flags = 0x1 , /* DISPLAYCONTROL_MONITOR_PRIMARY */
227- .Left = 0 ,
228- .Top = 0 ,
229- .Width = width ,
230- .Height = height ,
231- .PhysicalWidth = 0 ,
232- .PhysicalHeight = 0 ,
233- .Orientation = 0 ,
234- .DesktopScaleFactor = 0 ,
235- .DeviceScaleFactor = 0
236- }};
237-
238- /* Send display update notification if display channel is connected */
239- if (disp -> disp != NULL ) {
240-
241- guac_client * client = disp -> client ;
242- guac_rdp_client * rdp_client = (guac_rdp_client * ) client -> data ;
243-
244- pthread_mutex_lock (& (rdp_client -> message_lock ));
245- disp -> disp -> SendMonitorLayout (disp -> disp , 1 , monitors );
246- pthread_mutex_unlock (& (rdp_client -> message_lock ));
227+ /* Send display update notification if display channel is connected */
228+ else if (settings -> resize_method == GUAC_RESIZE_DISPLAY_UPDATE
229+ && disp -> disp != NULL ) {
230+
231+ /* Init monitors layout */
232+ DISPLAY_CONTROL_MONITOR_LAYOUT * monitors ;
233+ monitors = guac_mem_alloc (monitors_count * sizeof (DISPLAY_CONTROL_MONITOR_LAYOUT ));
234+
235+ for (int i = 0 ; i < monitors_count ; i ++ ) {
236+
237+ /* First monitor is the primary */
238+ int primary_monitor = (i == 0 ? 1 : 0 );
239+
240+ /* Shift each monitor to the right */
241+ int monitor_left = i * width ;
247242
243+ /* Get current monitor */
244+ DISPLAY_CONTROL_MONITOR_LAYOUT * monitor = & monitors [i ];
245+
246+ /* Set current monitor properties */
247+ monitor -> Flags = primary_monitor ;
248+ monitor -> Left = monitor_left ;
249+ monitor -> Top = 0 ;
250+ monitor -> Width = width ;
251+ monitor -> Height = height ;
252+ monitor -> Orientation = 0 ;
253+ monitor -> PhysicalWidth = 0 ;
254+ monitor -> PhysicalHeight = 0 ;
248255 }
249256
257+ /* Send display update notification */
258+ guac_client * client = disp -> client ;
259+ guac_rdp_client * rdp_client = (guac_rdp_client * ) client -> data ;
260+
261+ pthread_mutex_lock (& (rdp_client -> message_lock ));
262+ disp -> disp -> SendMonitorLayout (disp -> disp , monitors_count , monitors );
263+ pthread_mutex_unlock (& (rdp_client -> message_lock ));
264+
265+ guac_mem_free (monitors );
266+
250267 }
251268
252269}
0 commit comments