Skip to content

Commit

Permalink
WPF - OnWindowStateChanged only call WasHidden(false) when previous s…
Browse files Browse the repository at this point in the history
…tate was Minimized

Store the previous window state and only call IBrowserHost.WasHidden(false) if the browser was
previous hidden. Call isn't required when transitioning between Normal and Maximized
  • Loading branch information
amaitland committed Jul 27, 2019
1 parent 75fc173 commit e270d24
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions CefSharp.Wpf/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBrowser
/// View Rectangle used by <see cref="GetViewRect"/>
/// </summary>
private Rect viewRect;

/// <summary>
/// Store the previous window state, used to determine if the
/// Windows was previous <see cref="WindowState.Minimized"/>
/// and resume rendering
/// </summary>
private WindowState previousWindowState;
/// <summary>
/// The source
/// </summary>
Expand Down Expand Up @@ -743,7 +748,7 @@ private void InternalDispose(bool disposing)

var screenInfo = new ScreenInfo
{
DeviceScaleFactor = (float)DpiScaleFactor,
DeviceScaleFactor = DpiScaleFactor,
Rect = rect,
AvailableRect = availableRect
};
Expand Down Expand Up @@ -1733,7 +1738,7 @@ private void OnWindowStateChanged(object sender, EventArgs e)
case WindowState.Normal:
case WindowState.Maximized:
{
if (browser != null)
if (previousWindowState == WindowState.Minimized && browser != null)
{
browser.GetHost().WasHidden(false);
}
Expand All @@ -1748,6 +1753,8 @@ private void OnWindowStateChanged(object sender, EventArgs e)
break;
}
}

previousWindowState = window.WindowState;
}

/// <summary>
Expand Down

0 comments on commit e270d24

Please sign in to comment.