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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
15 additions and
3 deletions
-
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>
|
|
|
|
|