@@ -479,6 +479,8 @@ impl iron_remote_desktop::Session for Session {
479479 connection_result. desktop_size . height ,
480480 ) ;
481481
482+ let mut requested_resize = None ;
483+
482484 let mut active_stage = ActiveStage :: new ( connection_result) ;
483485
484486 let disconnect_reason = ' outer: loop {
@@ -542,9 +544,7 @@ impl iron_remote_desktop::Session for Session {
542544 warn!( "Resize event ignored: width or height is zero" ) ;
543545 Vec :: new( )
544546 } else if let Some ( response_frame) = active_stage. encode_resize( width, height, scale_factor, physical_size) {
545- self . render_canvas. set_width( width) ;
546- self . render_canvas. set_height( height) ;
547- gui. resize( NonZeroU32 :: new( width) . unwrap( ) , NonZeroU32 :: new( height) . unwrap( ) ) ;
547+ requested_resize = Some ( ( NonZeroU32 :: new( width) . unwrap( ) , NonZeroU32 :: new( height) . unwrap( ) ) ) ;
548548 vec![ ActiveStageOutput :: ResponseFrame ( response_frame?) ]
549549 } else {
550550 debug!( "Resize event ignored" ) ;
@@ -675,6 +675,16 @@ impl iron_remote_desktop::Session for Session {
675675 // Execute the Deactivation-Reactivation Sequence:
676676 // https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/dfc234ce-481a-4674-9a5d-2a7bafb14432
677677 debug ! ( "Received Server Deactivate All PDU, executing Deactivation-Reactivation Sequence" ) ;
678+
679+ // We need to perform resize after receiving the Deactivate All PDU, because there may be frames
680+ // with the previous dimensions arriving between the resize request and this message.
681+ if let Some ( ( width, height) ) = requested_resize {
682+ self . render_canvas . set_width ( width. get ( ) ) ;
683+ self . render_canvas . set_height ( height. get ( ) ) ;
684+ gui. resize ( width, height) ;
685+ requested_resize = None ;
686+ }
687+
678688 let mut buf = WriteBuf :: new ( ) ;
679689 ' activation_seq: loop {
680690 let written =
0 commit comments