mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
CA-249856 - XenCenter Keyboard shortcuts not working properly on VM console when remote desktop mode
This commit is contained in:
parent
ea6a082136
commit
3ea6d56983
@ -46,17 +46,19 @@ namespace XenAdmin.ConsoleView
|
||||
|
||||
private Size size;
|
||||
|
||||
private bool allowDisplayUpdate;
|
||||
|
||||
private readonly ContainerControl parent;
|
||||
|
||||
/// <summary>
|
||||
/// http://msdn2.microsoft.com/en-us/library/aa383022(VS.85).aspx
|
||||
/// </summary>
|
||||
private MsRdpClient8 rdpClient8 = null;
|
||||
private MsRdpClient9 rdpClient9 = null;
|
||||
|
||||
private MsRdpClient6 rdpClient6 = null;
|
||||
|
||||
/// <summary>
|
||||
/// This will be equal to rdpClient8, if the DLL that we've got is version 8, otherwise equal to
|
||||
/// This will be equal to rdpClient9, if the DLL that we've got is version 8, otherwise equal to
|
||||
/// rdpClient6.
|
||||
/// </summary>
|
||||
private AxHost rdpControl = null;
|
||||
@ -69,18 +71,22 @@ namespace XenAdmin.ConsoleView
|
||||
this.size = size;
|
||||
try
|
||||
{
|
||||
rdpControl = rdpClient8 = new MsRdpClient8();
|
||||
rdpControl = rdpClient9 = new MsRdpClient9();
|
||||
RDPConfigure(size);
|
||||
|
||||
//add event handler for when RDP display is resized
|
||||
rdpClient9.OnRemoteDesktopSizeChange += rdpClient_OnRemoteDesktopSizeChange;
|
||||
|
||||
// CA-96135: Try adding rdpControl to parent.Controls list; this will throw exception when
|
||||
// MsRdpClient8 control cannot be created (there is no appropriate version of dll present)
|
||||
parent.Controls.Add(rdpControl);
|
||||
allowDisplayUpdate = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (parent.Controls.Contains(rdpControl))
|
||||
parent.Controls.Remove(rdpControl);
|
||||
rdpClient8 = null;
|
||||
rdpClient9 = null;
|
||||
rdpControl = rdpClient6 = new MsRdpClient6();
|
||||
RDPConfigure(size);
|
||||
parent.Controls.Add(rdpControl);
|
||||
@ -113,10 +119,10 @@ namespace XenAdmin.ConsoleView
|
||||
if (rdpControl == null)
|
||||
return;
|
||||
|
||||
if (rdpClient8 == null)
|
||||
if (rdpClient9 == null)
|
||||
rdpClient6.OnDisconnected += rdpClient_OnDisconnected;
|
||||
else
|
||||
rdpClient8.OnDisconnected += rdpClient_OnDisconnected;
|
||||
rdpClient9.OnDisconnected += rdpClient_OnDisconnected;
|
||||
}
|
||||
|
||||
private void RDPSetSettings()
|
||||
@ -124,7 +130,7 @@ namespace XenAdmin.ConsoleView
|
||||
if (rdpControl == null)
|
||||
return;
|
||||
|
||||
if (rdpClient8 == null)
|
||||
if (rdpClient9 == null)
|
||||
{
|
||||
rdpClient6.SecuredSettings2.KeyboardHookMode = Properties.Settings.Default.WindowsShortcuts ? 1 : 0;
|
||||
rdpClient6.SecuredSettings2.AudioRedirectionMode = Properties.Settings.Default.ReceiveSoundFromRDP ? 0 : 1;
|
||||
@ -136,13 +142,13 @@ namespace XenAdmin.ConsoleView
|
||||
}
|
||||
else
|
||||
{
|
||||
rdpClient8.SecuredSettings2.KeyboardHookMode = Properties.Settings.Default.WindowsShortcuts ? 1 : 0;
|
||||
rdpClient8.SecuredSettings2.AudioRedirectionMode = Properties.Settings.Default.ReceiveSoundFromRDP ? 0 : 1;
|
||||
rdpClient8.AdvancedSettings3.DisableRdpdr = Properties.Settings.Default.ClipboardAndPrinterRedirection ? 0 : 1;
|
||||
rdpClient8.AdvancedSettings7.ConnectToAdministerServer = Properties.Settings.Default.ConnectToServerConsole;
|
||||
rdpClient9.SecuredSettings2.KeyboardHookMode = Properties.Settings.Default.WindowsShortcuts ? 1 : 0;
|
||||
rdpClient9.SecuredSettings2.AudioRedirectionMode = Properties.Settings.Default.ReceiveSoundFromRDP ? 0 : 1;
|
||||
rdpClient9.AdvancedSettings3.DisableRdpdr = Properties.Settings.Default.ClipboardAndPrinterRedirection ? 0 : 1;
|
||||
rdpClient9.AdvancedSettings7.ConnectToAdministerServer = Properties.Settings.Default.ConnectToServerConsole;
|
||||
//CA-103910 - enable NLA
|
||||
rdpClient8.AdvancedSettings5.AuthenticationLevel = 2;
|
||||
rdpClient8.AdvancedSettings7.EnableCredSspSupport = true;
|
||||
rdpClient9.AdvancedSettings5.AuthenticationLevel = 2;
|
||||
rdpClient9.AdvancedSettings7.EnableCredSspSupport = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,12 +158,12 @@ namespace XenAdmin.ConsoleView
|
||||
return;
|
||||
|
||||
Log.DebugFormat("Connecting RDPClient{0} using server '{1}', width '{2}' and height '{3}'",
|
||||
rdpClient8 == null ? "6" : "8",
|
||||
rdpClient9 == null ? "6" : "9",
|
||||
rdpIP,
|
||||
w,
|
||||
h);
|
||||
|
||||
if (rdpClient8 == null)
|
||||
if (rdpClient9 == null)
|
||||
{
|
||||
rdpClient6.Server = rdpIP;
|
||||
rdpClient6.DesktopWidth = w;
|
||||
@ -166,40 +172,47 @@ namespace XenAdmin.ConsoleView
|
||||
}
|
||||
else
|
||||
{
|
||||
rdpClient8.Server = rdpIP;
|
||||
rdpClient8.DesktopWidth = w;
|
||||
rdpClient8.DesktopHeight = h;
|
||||
rdpClient8.Connect();
|
||||
rdpClient9.Server = rdpIP;
|
||||
rdpClient9.DesktopWidth = w;
|
||||
rdpClient9.DesktopHeight = h;
|
||||
rdpClient9.Connect();
|
||||
}
|
||||
}
|
||||
|
||||
public void Reconnect( int width, int height)
|
||||
public void UpdateDisplay( int width, int height)
|
||||
{
|
||||
if (rdpControl == null)
|
||||
return;
|
||||
|
||||
Log.DebugFormat("Reconnecting RDPClient8 using width '{0}' and height '{1}'", width, height);
|
||||
|
||||
if (Connected && rdpClient8 != null)
|
||||
Log.DebugFormat("Updating display settings using width '{0}' and height '{1}'", width, height);
|
||||
if (Connected && rdpClient9 != null && allowDisplayUpdate)
|
||||
{
|
||||
rdpClient8.Size = new Size(width, height);
|
||||
rdpClient8.Reconnect((uint)width, (uint)height);
|
||||
rdpClient9.Size = new Size(width, height);
|
||||
try
|
||||
{
|
||||
rdpClient9.UpdateSessionDisplaySettings((uint)width, (uint)height, (uint)width, (uint)height, 1, 1, 1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
allowDisplayUpdate = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private bool Connected
|
||||
{
|
||||
get { return rdpControl == null ? false : (rdpClient8 == null ? rdpClient6.Connected == 1 : rdpClient8.Connected == 1); }
|
||||
get { return rdpControl == null ? false : (rdpClient9 == null ? rdpClient6.Connected == 1 : rdpClient9.Connected == 1); }
|
||||
}
|
||||
|
||||
private int DesktopHeight
|
||||
{
|
||||
get { return rdpControl == null ? 0 : (rdpClient8 == null ? rdpClient6.DesktopHeight : rdpClient8.DesktopHeight); }
|
||||
get { return rdpControl == null ? 0 : (rdpClient9 == null ? rdpClient6.DesktopHeight : rdpClient9.DesktopHeight); }
|
||||
}
|
||||
|
||||
private int DesktopWidth
|
||||
{
|
||||
get { return rdpControl == null ? 0 : (rdpClient8 == null ? rdpClient6.DesktopWidth : rdpClient8.DesktopWidth); }
|
||||
get { return rdpControl == null ? 0 : (rdpClient9 == null ? rdpClient6.DesktopWidth : rdpClient9.DesktopWidth); }
|
||||
}
|
||||
|
||||
private static readonly List<System.Windows.Forms.Timer> RdpCleanupTimers = new List<System.Windows.Forms.Timer>();
|
||||
@ -212,6 +225,15 @@ namespace XenAdmin.ConsoleView
|
||||
|
||||
}
|
||||
|
||||
//refresh to draw focus border in correct position after display is updated
|
||||
void rdpClient_OnRemoteDesktopSizeChange(object sender, AxMSTSCLib.IMsTscAxEvents_OnRemoteDesktopSizeChangeEvent e)
|
||||
{
|
||||
Program.AssertOnEventThread();
|
||||
|
||||
if(parent != null)
|
||||
parent.Refresh();
|
||||
}
|
||||
|
||||
public void Connect(string rdpIP)
|
||||
{
|
||||
try
|
||||
@ -235,10 +257,10 @@ namespace XenAdmin.ConsoleView
|
||||
{
|
||||
if (Connected)
|
||||
{
|
||||
if (rdpClient8 == null)
|
||||
if (rdpClient9 == null)
|
||||
rdpClient6.Disconnect();
|
||||
else
|
||||
rdpClient8.Disconnect();
|
||||
rdpClient9.Disconnect();
|
||||
}
|
||||
}
|
||||
catch(InvalidComObjectException ex)
|
||||
|
@ -1394,14 +1394,14 @@ namespace XenAdmin.ConsoleView
|
||||
if (fullscreen)
|
||||
{
|
||||
rdpClient.rdpLocationOffset = new Point(0, 0);
|
||||
rdpClient.Reconnect(this.Size.Width, this.Size.Height);
|
||||
rdpClient.UpdateDisplay(this.Size.Width, this.Size.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oldSize.Equals(this.Size))
|
||||
return;
|
||||
rdpClient.rdpLocationOffset = new Point(2, 2);
|
||||
rdpClient.Reconnect(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET);
|
||||
rdpClient.UpdateDisplay(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET);
|
||||
oldSize = new Size(this.Size.Width, this.Size.Height);
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,9 @@
|
||||
|
||||
namespace XenAdmin.RDP
|
||||
{
|
||||
public class MsRdpClient8 : AxMSTSCLib.AxMsRdpClient8
|
||||
public class MsRdpClient9 : AxMSTSCLib.AxMsRdpClient9
|
||||
{
|
||||
public MsRdpClient8()
|
||||
public MsRdpClient9()
|
||||
: base()
|
||||
{
|
||||
}
|
@ -3030,7 +3030,7 @@
|
||||
<DependentUpon>LVMoHBAWarningDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Network\XenConnectionUI.cs" />
|
||||
<Compile Include="RDP\MsRdpClient8.cs">
|
||||
<Compile Include="RDP\MsRdpClient9.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="RDP\MsRdpClient6.cs">
|
||||
|
Loading…
Reference in New Issue
Block a user