diff options
author | Jose Medrano <josmed@microsoft.com> | 2022-04-06 17:47:16 +0300 |
---|---|---|
committer | Jose Medrano <josmed@microsoft.com> | 2022-04-06 17:47:16 +0300 |
commit | 68bb09f96c2c87b18a5b7100134b64caae7e9c26 (patch) | |
tree | 31b01ad432aa444a691454d10099411f8667885c | |
parent | f6c1ecf3e4d8ece568e3009b70979f10e511c261 (diff) |
[WindowFrameBackend] We only add the parenting if the window was not already added+center
-rw-r--r-- | Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs b/Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs index b520a67b..f96b4ce7 100644 --- a/Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs +++ b/Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs @@ -96,20 +96,17 @@ namespace Xwt.Mac internal void InternalShow () { Window.MakeKeyAndOrderFront (MacEngine.App); - if (Window.ParentWindow != null) { - if (!Window.ParentWindow.ChildWindows.Contains (Window)) - Window.ParentWindow.AddChildWindow (Window, NSWindowOrderingMode.Above); - - // always use NSWindow for alignment when running in guest mode and - // don't rely on AddChildWindow to position the window correctly - if (!(Window.ParentWindow is WindowBackend)) { - var parentBounds = MacDesktopBackend.ToDesktopRect (Window.ParentWindow.ContentRectFor (Window.ParentWindow.Frame)); - var bounds = ((IWindowFrameBackend)this).Bounds; - bounds.X = parentBounds.Center.X - (Window.Frame.Width / 2); - bounds.Y = parentBounds.Center.Y - (Window.Frame.Height / 2); - ((IWindowFrameBackend)this).Bounds = bounds; - } + var parentWindow = Window.ParentWindow; + + if (parentWindow != null && Visible) + { + //if there is any child window we remove it + if (!parentWindow.ChildWindows.Contains (Window)) + parentWindow.AddChildWindow (Window, NSWindowOrderingMode.Above); } + + //we center in any case + Util.CenterWindow(Window, parentWindow); } public void Present () |