Enable size change without reconnect

Use IMsRdpClient9::UpdateSessionDisplaySettings to dynamically update the
session display settings without reconnecting. RDP Version needs to be
Rdc9 or Highest for this to work.

Fixes #1546
This commit is contained in:
Daniel Triendl
2022-03-18 19:17:46 +01:00
parent 85f7be1d79
commit 2fb0ab1d91
2 changed files with 39 additions and 25 deletions

View File

@@ -29,7 +29,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
protected set protected set
{ {
base.SmartSize = value; base.SmartSize = value;
ReconnectForResize(); DoResizeClient();
} }
} }
@@ -39,7 +39,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
protected set protected set
{ {
base.Fullscreen = value; base.Fullscreen = value;
ReconnectForResize(); DoResizeClient();
} }
} }
@@ -50,19 +50,19 @@ namespace mRemoteNG.Connection.Protocol.RDP
public override void Resize(object sender, EventArgs e) public override void Resize(object sender, EventArgs e)
{ {
if (DoResize() && _controlBeginningSize.IsEmpty) if (DoResizeControl() && _controlBeginningSize.IsEmpty)
{ {
ReconnectForResize(); DoResizeClient();
} }
base.Resize(sender, e); base.Resize(sender, e);
} }
public override void ResizeEnd(object sender, EventArgs e) public override void ResizeEnd(object sender, EventArgs e)
{ {
DoResize(); DoResizeControl();
if (!(Control.Size == _controlBeginningSize)) if (!(Control.Size == _controlBeginningSize))
{ {
ReconnectForResize(); DoResizeClient();
} }
_controlBeginningSize = Size.Empty; _controlBeginningSize = Size.Empty;
} }
@@ -72,7 +72,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
return new AxMsRdpClient8NotSafeForScripting(); return new AxMsRdpClient8NotSafeForScripting();
} }
private void ReconnectForResize() private void DoResizeClient()
{ {
if (!loginComplete) if (!loginComplete)
return; return;
@@ -94,8 +94,8 @@ namespace mRemoteNG.Connection.Protocol.RDP
{ {
var size = Fullscreen var size = Fullscreen
? Screen.FromControl(Control).Bounds.Size ? Screen.FromControl(Control).Bounds.Size
: Control.Size; : Control.Size;
RdpClient8.Reconnect((uint)size.Width, (uint)size.Height); UpdateSessionDisplaySettings((uint)size.Width, (uint)size.Height);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -106,7 +106,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
} }
} }
private bool DoResize() private bool DoResizeControl()
{ {
Control.Location = InterfaceControl.Location; Control.Location = InterfaceControl.Location;
// kmscode - this doesn't look right to me. But I'm not aware of any functionality issues with this currently... // kmscode - this doesn't look right to me. But I'm not aware of any functionality issues with this currently...
@@ -120,5 +120,10 @@ namespace mRemoteNG.Connection.Protocol.RDP
return false; return false;
} }
} }
protected virtual void UpdateSessionDisplaySettings(uint width, uint height)
{
RdpClient8.Reconnect(width, height);
}
} }
} }

View File

@@ -1,15 +1,24 @@
using System.Windows.Forms; using System.Windows.Forms;
using AxMSTSCLib; using AxMSTSCLib;
using MSTSCLib;
namespace mRemoteNG.Connection.Protocol.RDP
{ namespace mRemoteNG.Connection.Protocol.RDP
public class RdpProtocol9 : RdpProtocol8 {
{ public class RdpProtocol9 : RdpProtocol8
protected override RdpVersion RdpProtocolVersion => RdpVersion.Rdc9; {
private MsRdpClient9NotSafeForScripting RdpClient9 =>
protected override AxHost CreateActiveXRdpClientControl() (MsRdpClient9NotSafeForScripting)((AxHost)Control).GetOcx();
{
return new AxMsRdpClient9NotSafeForScripting(); protected override RdpVersion RdpProtocolVersion => RdpVersion.Rdc9;
}
} protected override AxHost CreateActiveXRdpClientControl()
} {
return new AxMsRdpClient9NotSafeForScripting();
}
protected override void UpdateSessionDisplaySettings(uint width, uint height)
{
RdpClient9.UpdateSessionDisplaySettings(width, height, width, height, 0, 1, 1);
}
}
}