Browse Source

Merge pull request #1553 from AvaloniaUI/feature/stop-renderer-on-minimize

Stop renderer on Window minimize.
pull/1634/merge
Steven Kirk 8 years ago
committed by GitHub
parent
commit
966294a778
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/Avalonia.Controls/Window.cs

18
src/Avalonia.Controls/Window.cs

@ -145,11 +145,9 @@ namespace Avalonia.Controls
: base(impl)
{
impl.Closing = HandleClosing;
impl.WindowStateChanged = HandleWindowStateChanged;
_maxPlatformClientSize = PlatformImpl?.MaxClientSize ?? default(Size);
Screens = new Screens(PlatformImpl?.Screen);
if (PlatformImpl != null)
PlatformImpl.WindowStateChanged = s => WindowState = s;
}
/// <inheritdoc/>
@ -318,6 +316,20 @@ namespace Avalonia.Controls
return args.Cancel;
}
protected virtual void HandleWindowStateChanged(WindowState state)
{
WindowState = state;
if (state == WindowState.Minimized)
{
Renderer.Stop();
}
else
{
Renderer.Start();
}
}
/// <summary>
/// Hides the window but does not close it.
/// </summary>

Loading…
Cancel
Save