Skip to content
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Avalonia.Controls/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,19 @@ void SetIsEnabled(IEnumerable<Window> windows, bool isEnabled)

void SetWindowStartupLocation()
{
var scaling = PlatformImpl?.Scaling ?? 1;
if (WindowStartupLocation == WindowStartupLocation.CenterScreen)
{
var screen = Screens.ScreenFromPoint(Bounds.Position);

if (screen != null)
Position = screen.WorkingArea.CenterRect(new Rect(ClientSize)).Position;
Position = screen.WorkingArea.CenterRect(new Rect(ClientSize * scaling)).Position;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately this doesn't work for me.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is because the ClientSize is being treated as screen pixels somewhere and isn't being scaled. This is probably a backend-specific bug as I'm not getting it on Win32.

Which backend are you running on?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danwalmsley any further info here?

}
else if (WindowStartupLocation == WindowStartupLocation.CenterOwner)
{
if (Owner != null)
{
var positionAsSize = Owner.ClientSize / 2 - ClientSize / 2;
var positionAsSize = (Owner.ClientSize / 2 - ClientSize / 2) * scaling;
Position = Owner.Position + new Point(positionAsSize.Width, positionAsSize.Height);
}
}
Expand Down