diff --git a/src/Avalonia.Controls/Screens.cs b/src/Avalonia.Controls/Screens.cs
index 22f9c0832a..60d5358c49 100644
--- a/src/Avalonia.Controls/Screens.cs
+++ b/src/Avalonia.Controls/Screens.cs
@@ -1,8 +1,7 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Platform;
-using Avalonia.VisualTree;
#nullable enable
@@ -38,21 +37,58 @@ namespace Avalonia.Controls
_iScreenImpl = iScreenImpl;
}
+ ///
+ /// Retrieves a Screen for the display that contains the rectangle.
+ ///
+ /// Bounds that specifies the area for which to retrieve the display.
+ /// The .
public Screen? ScreenFromBounds(PixelRect bounds)
{
return _iScreenImpl.ScreenFromRect(bounds);
}
+ ///
+ /// Retrieves a Screen for the display that contains the specified .
+ ///
+ /// The window for which to retrieve the Screen.
+ /// Window platform implementation was already disposed.
+ /// The .
+ public Screen? ScreenFromWindow(WindowBase window)
+ {
+ if (window.PlatformImpl is null)
+ {
+ throw new ObjectDisposedException("Window platform implementation was already disposed.");
+ }
+
+ return _iScreenImpl.ScreenFromWindow(window.PlatformImpl);
+ }
+
+ ///
+ /// Retrieves a Screen for the display that contains the specified .
+ ///
+ /// The window impl for which to retrieve the Screen.
+ /// The .
+ [Obsolete("Use ScreenFromWindow(WindowBase) overload.")]
public Screen? ScreenFromWindow(IWindowBaseImpl window)
{
return _iScreenImpl.ScreenFromWindow(window);
}
+ ///
+ /// Retrieves a Screen for the display that contains the specified point.
+ ///
+ /// A Point that specifies the location for which to retrieve a Screen.
+ /// The .
public Screen? ScreenFromPoint(PixelPoint point)
{
return _iScreenImpl.ScreenFromPoint(point);
}
+ ///
+ /// Retrieves a Screen for the display that contains the specified .
+ ///
+ /// A Visual for which to retrieve a Screen.
+ /// The .
public Screen? ScreenFromVisual(Visual visual)
{
var tl = visual.PointToScreen(visual.Bounds.TopLeft);
diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs
index 48edb81b16..66cce89b9d 100644
--- a/src/Avalonia.Controls/Window.cs
+++ b/src/Avalonia.Controls/Window.cs
@@ -713,7 +713,7 @@ namespace Avalonia.Controls
Owner = owner;
owner?.AddChild(this, false);
- SetWindowStartupLocation(owner?.PlatformImpl);
+ SetWindowStartupLocation(owner);
PlatformImpl?.Show(ShowActivated, false);
Renderer.Start();
@@ -789,7 +789,7 @@ namespace Avalonia.Controls
Owner = owner;
owner.AddChild(this, true);
- SetWindowStartupLocation(owner.PlatformImpl);
+ SetWindowStartupLocation(owner);
PlatformImpl?.Show(ShowActivated, true);
@@ -870,7 +870,7 @@ namespace Avalonia.Controls
}
}
- private void SetWindowStartupLocation(IWindowBaseImpl? owner = null)
+ private void SetWindowStartupLocation(Window? owner = null)
{
var startupLocation = WindowStartupLocation;