CA-249856: Fix console position and focus rectangle drawing on resize

Also ensuring that if the UpdateSessionDisplaySettings function (which we use for resize) is not supported, then we display the console centered in the parent window and with scrollbars if needed

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2017-04-25 14:07:29 +01:00
parent 3ea6d56983
commit 42df02734a
3 changed files with 24 additions and 23 deletions

View File

@ -97,9 +97,9 @@ namespace XenAdmin.ConsoleView
private void RDPConfigure(Size currentConsoleSize)
{
rdpControl.BeginInit();
rdpLocationOffset = new Point(2, 2); //small offset to accomodate focus rectangle
rdpLocationOffset = new Point(3, 3); //small offset to accomodate focus rectangle
rdpControl.Dock = DockStyle.None;
rdpControl.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right);
rdpControl.Anchor = AnchorStyles.None;
rdpControl.Size = currentConsoleSize;
RDPAddOnDisconnected();
rdpControl.Enter += RdpEnter;
@ -179,24 +179,27 @@ namespace XenAdmin.ConsoleView
}
}
public void UpdateDisplay( int width, int height)
public void UpdateDisplay(int width, int height, Point locationOffset)
{
if (rdpControl == null)
return;
Log.DebugFormat("Updating display settings using width '{0}' and height '{1}'", width, height);
if (Connected && rdpClient9 != null && allowDisplayUpdate)
{
rdpClient9.Size = new Size(width, height);
try
{
Log.DebugFormat("Updating display settings using width '{0}' and height '{1}'", width, height);
rdpClient9.UpdateSessionDisplaySettings((uint)width, (uint)height, (uint)width, (uint)height, 1, 1, 1);
rdpClient9.Size = new Size(width, height);
rdpLocationOffset = locationOffset;
parent.AutoScroll = false;
}
catch
{
allowDisplayUpdate = false;
parent.AutoScroll = true;
parent.AutoScrollMinSize = rdpClient9.Size;
}
}
}
@ -230,8 +233,11 @@ namespace XenAdmin.ConsoleView
{
Program.AssertOnEventThread();
if(parent != null)
parent.Refresh();
if (rdpControl == null || parent == null)
return;
rdpControl.Size = DesktopSize;
parent.Refresh();
}
public void Connect(string rdpIP)

View File

@ -1050,7 +1050,7 @@ namespace XenAdmin.ConsoleView
fullscreenForm.Hide();
fullscreenForm.Dispose();
fullscreenForm = null;
UpdateRDPResolution(true);
UpdateRDPResolution(false);
}
//Everytime we toggle full screen I'm going to force an unpause to make sure we don't acidentally undock / dock a pause VNC

View File

@ -522,7 +522,7 @@ namespace XenAdmin.ConsoleView
bool wasFocused = false;
this.Controls.Clear();
//console size with some offset to accomodate focus rectangle
Size currentConsoleSize = new Size(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET); ;
Size currentConsoleSize = new Size(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET);
// Kill the old client.
if (RemoteConsole != null)
@ -556,6 +556,8 @@ namespace XenAdmin.ConsoleView
{
if (this.ParentForm is FullScreenForm)
currentConsoleSize = ((FullScreenForm)ParentForm).GetContentSize();
this.AutoScroll = true;
this.AutoScrollMinSize = oldSize;
rdpClient = new RdpClient(this, currentConsoleSize, ResizeHandler);
rdpClient.OnDisconnected += new EventHandler(parentVNCTabView.RdpDisconnectedHandler);
@ -1387,23 +1389,16 @@ namespace XenAdmin.ConsoleView
private Size oldSize;
public void UpdateRDPResolution(bool fullscreen = false)
{
if (rdpClient == null)
if (rdpClient == null || oldSize.Equals(this.Size))
return;
//no offsets in fullscreen mode because there is no need to accomodate focus border
if (fullscreen)
{
rdpClient.rdpLocationOffset = new Point(0, 0);
rdpClient.UpdateDisplay(this.Size.Width, this.Size.Height);
}
else
{
if (oldSize.Equals(this.Size))
return;
rdpClient.rdpLocationOffset = new Point(2, 2);
rdpClient.UpdateDisplay(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET);
oldSize = new Size(this.Size.Width, this.Size.Height);
}
rdpClient.UpdateDisplay(this.Size.Width, this.Size.Height, new Point(0,0));
else
rdpClient.UpdateDisplay(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET, new Point(3,3));
oldSize = new Size(this.Size.Width, this.Size.Height);
Refresh();
}
}
}