Skip to content

Commit

Permalink
b/374823115 Use IsContainerFullScreen for state tracking (#1534)
Browse files Browse the repository at this point in the history
- Use IsContainerFullScreen instead of IsFullScreen to
  determine the connection state because IsFullScreen
  doesn't immediately reflect the correct value after
  leaving full-screen mode.
- This fixes an issue where an RDP client was left in a defunct
  state after the session timed out in full-screen mode.
  • Loading branch information
jpassing authored Oct 21, 2024
1 parent 0f6c181 commit 5c7fd11
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
18 changes: 15 additions & 3 deletions sources/Google.Solutions.Terminal/Controls/ClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,19 @@ protected ClientBase()
this.StateChanged += (_, args) =>
{
this.statePanel.State = this.State;
this.statePanel.Visible = !this.IsFullScreen && (
//
// NB. We check IsContainerFullScreen as opposed to
// IsFullScreen here because IsFullScreen (at least
// in the case of the RdpClient) is only updated
// asynchronously after leaving full-screen.
//
// One particular example where this difference shows
// is when the RDP session is disconnected because of
// a session timeout while in full-screen mode.
//
this.statePanel.Visible = !this.IsContainerFullScreen && (
this.State == ConnectionState.NotConnected ||
this.State == ConnectionState.Disconnecting ||
this.State == ConnectionState.Connecting);
Expand All @@ -108,10 +120,10 @@ protected ClientBase()
}

/// <summary>
/// Check if the client is currently in full-screen mode.
/// Check if the client is currently hosted in a full-screen container.
/// </summary>
[Browsable(false)]
public virtual bool IsFullScreen
public virtual bool IsContainerFullScreen
{
get => false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public ClientDiagnosticsWindow(TClient client)
{
this.Client = client;

if (client is RdpClient rdpClient)
{
rdpClient.MainWindow = this;
}

SuspendLayout();
this.AutoScaleDimensions = new System.Drawing.SizeF(96, 96);
this.AutoScaleMode = AutoScaleMode.Dpi;
Expand Down
19 changes: 16 additions & 3 deletions sources/Google.Solutions.Terminal/Controls/RdpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected override void OnFormClosing(object sender, FormClosingEventArgs args)
args.Cancel = true;
return;
}
else if (this.IsFullScreen)
else if (this.IsContainerFullScreen)
{
//
// Veto this event as it would leave an orphaned full-screen
Expand Down Expand Up @@ -1168,13 +1168,18 @@ private static void MoveControls(Control source, Control target)
Debug.Assert(source.Controls.Count == 0);
}

public override bool IsContainerFullScreen
{
get => this.ContainerFullScreen;
}

/// <summary>
/// Gets or sets full-scren mode for the containing window.
///
/// This property should only be changed from within RDP
/// callbacks.
/// </summary>
internal bool ContainerFullScreen
protected bool ContainerFullScreen
{
get => fullScreenForm != null && fullScreenForm.Visible;
private set
Expand Down Expand Up @@ -1279,7 +1284,7 @@ private static bool IsFullScreenFormVisible
/// Check if the client is currently in full-screen mode.
/// </summary>
[Browsable(false)]
public override bool IsFullScreen
public bool IsFullScreen
{
get
{
Expand Down Expand Up @@ -1327,6 +1332,14 @@ public bool TryEnterFullScreen(Rectangle? customBounds)
return true;
}

/// <summary>
/// Enter full screen mode.
/// </summary>
public bool TryEnterFullScreen()
{
return TryEnterFullScreen(null);
}

/// <summary>
/// Leave full-screen mode.
/// </summary>
Expand Down

0 comments on commit 5c7fd11

Please sign in to comment.