Browse Source
Merge pull request #7730 from AvaloniaUI/fixes/7582-centerowner-minimized
Fall back from CenterOwner to CenterScreen when owner window is minimized.
pull/7736/head
Dan Walmsley
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
13 additions and
2 deletions
-
src/Avalonia.Controls/Window.cs
|
|
|
@ -859,6 +859,17 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
private void SetWindowStartupLocation(IWindowBaseImpl? owner = null) |
|
|
|
{ |
|
|
|
var startupLocation = WindowStartupLocation; |
|
|
|
|
|
|
|
if (startupLocation == WindowStartupLocation.CenterOwner && |
|
|
|
Owner is Window ownerWindow && |
|
|
|
ownerWindow.WindowState == WindowState.Minimized) |
|
|
|
{ |
|
|
|
// If startup location is CenterOwner, but owner is minimized then fall back
|
|
|
|
// to CenterScreen. This behavior is consistent with WPF.
|
|
|
|
startupLocation = WindowStartupLocation.CenterScreen; |
|
|
|
} |
|
|
|
|
|
|
|
var scaling = owner?.DesktopScaling ?? PlatformImpl?.DesktopScaling ?? 1; |
|
|
|
|
|
|
|
// TODO: We really need non-client size here.
|
|
|
|
@ -866,7 +877,7 @@ namespace Avalonia.Controls |
|
|
|
PixelPoint.Origin, |
|
|
|
PixelSize.FromSize(ClientSize, scaling)); |
|
|
|
|
|
|
|
if (WindowStartupLocation == WindowStartupLocation.CenterScreen) |
|
|
|
if (startupLocation == WindowStartupLocation.CenterScreen) |
|
|
|
{ |
|
|
|
var screen = Screens.ScreenFromPoint(owner?.Position ?? Position); |
|
|
|
|
|
|
|
@ -875,7 +886,7 @@ namespace Avalonia.Controls |
|
|
|
Position = screen.WorkingArea.CenterRect(rect).Position; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (WindowStartupLocation == WindowStartupLocation.CenterOwner) |
|
|
|
else if (startupLocation == WindowStartupLocation.CenterOwner) |
|
|
|
{ |
|
|
|
if (owner != null) |
|
|
|
{ |
|
|
|
|