diff --git a/source/Components/AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs b/source/Components/AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs index 73c3aa3c..8f84e548 100644 --- a/source/Components/AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs +++ b/source/Components/AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs @@ -162,7 +162,7 @@ void IOverlayWindowHost.HideOverlayWindow() IOverlayWindow IOverlayWindowHost.ShowOverlayWindow(LayoutFloatingWindowControl draggingWindow) { - CreateOverlayWindow(); + CreateOverlayWindow(draggingWindow); _overlayWindow.EnableDropTargets(); _overlayWindow.Show(); return _overlayWindow; @@ -295,10 +295,20 @@ private void _model_IsVisibleChanged(object sender, EventArgs e) if (!IsVisible && _model.IsVisible) Show(); } - private void CreateOverlayWindow() + private void CreateOverlayWindow(LayoutFloatingWindowControl draggingWindow) { if (_overlayWindow == null) _overlayWindow = new OverlayWindow(this); - _overlayWindow.Owner = Window.GetWindow(this); + + // Usually, the overlay window is made a child of the main window. However, if the floating + // window being dragged isn't also a child of the main window (because OwnedByDockingManagerWindow + // is set to false to allow the parent window to be minimized independently of floating windows), + // this causes the floating window to be moved behind the main window. Just not setting the parent + // seems to work acceptably here in that case. + if (draggingWindow?.OwnedByDockingManagerWindow ?? true) + _overlayWindow.Owner = Window.GetWindow(this); + else + _overlayWindow.Owner = null; + var rectWindow = new Rect(this.PointToScreenDPIWithoutFlowDirection(new Point()), this.TransformActualSizeToAncestor()); _overlayWindow.Left = rectWindow.Left; _overlayWindow.Top = rectWindow.Top; @@ -417,4 +427,4 @@ private void OnExecuteCloseWindowCommand(object parameter) #endregion Private Methods } -} \ No newline at end of file +} diff --git a/source/Components/AvalonDock/Controls/LayoutDocumentFloatingWindowControl.cs b/source/Components/AvalonDock/Controls/LayoutDocumentFloatingWindowControl.cs index db93a0f1..c394fbea 100644 --- a/source/Components/AvalonDock/Controls/LayoutDocumentFloatingWindowControl.cs +++ b/source/Components/AvalonDock/Controls/LayoutDocumentFloatingWindowControl.cs @@ -225,10 +225,20 @@ bool HitTest(Point dragPoint) private OverlayWindow _overlayWindow = null; - private void CreateOverlayWindow() + private void CreateOverlayWindow(LayoutFloatingWindowControl draggingWindow) { if (_overlayWindow == null) _overlayWindow = new OverlayWindow(this); - _overlayWindow.Owner = Window.GetWindow(this); + + // Usually, the overlay window is made a child of the main window. However, if the floating + // window being dragged isn't also a child of the main window (because OwnedByDockingManagerWindow + // is set to false to allow the parent window to be minimized independently of floating windows), + // this causes the floating window to be moved behind the main window. Just not setting the parent + // seems to work acceptably here in that case. + if (draggingWindow?.OwnedByDockingManagerWindow ?? true) + _overlayWindow.Owner = Window.GetWindow(this); + else + _overlayWindow.Owner = null; + var rectWindow = new Rect(this.PointToScreenDPIWithoutFlowDirection(new Point()), this.TransformActualSizeToAncestor()); _overlayWindow.Left = rectWindow.Left; _overlayWindow.Top = rectWindow.Top; @@ -238,7 +248,7 @@ private void CreateOverlayWindow() IOverlayWindow IOverlayWindowHost.ShowOverlayWindow(LayoutFloatingWindowControl draggingWindow) { - CreateOverlayWindow(); + CreateOverlayWindow(draggingWindow); _overlayWindow.EnableDropTargets(); _overlayWindow.Show(); return _overlayWindow; @@ -419,4 +429,4 @@ private void OnExecuteCloseWindowCommand(object parameter) #endregion Private Methods } -} \ No newline at end of file +} diff --git a/source/Components/AvalonDock/DockingManager.cs b/source/Components/AvalonDock/DockingManager.cs index 7ccb27ba..2d0ac381 100644 --- a/source/Components/AvalonDock/DockingManager.cs +++ b/source/Components/AvalonDock/DockingManager.cs @@ -1436,7 +1436,7 @@ bool HitTest(Point dragPoint) /// IOverlayWindow IOverlayWindowHost.ShowOverlayWindow(LayoutFloatingWindowControl draggingWindow) { - CreateOverlayWindow(); + CreateOverlayWindow(draggingWindow); _overlayWindow.EnableDropTargets(); _overlayWindow.Show(); return _overlayWindow; @@ -2095,13 +2095,22 @@ private void SetupAutoHideWindow() SetAutoHideWindow(new LayoutAutoHideWindowControl()); } - private void CreateOverlayWindow() + private void CreateOverlayWindow(LayoutFloatingWindowControl draggingWindow = null) { if (_overlayWindow == null) { _overlayWindow = new OverlayWindow(this); } - _overlayWindow.Owner = Window.GetWindow(this); + + // Usually, the overlay window is made a child of the main window. However, if the floating + // window being dragged isn't also a child of the main window (because OwnedByDockingManagerWindow + // is set to false to allow the parent window to be minimized independently of floating windows), + // this causes the floating window to be moved behind the main window. Just not setting the parent + // seems to work acceptably here in that case. + if (draggingWindow?.OwnedByDockingManagerWindow ?? true) + _overlayWindow.Owner = Window.GetWindow(this); + else + _overlayWindow.Owner = null; var rectWindow = new Rect(this.PointToScreenDPIWithoutFlowDirection(new Point()), this.TransformActualSizeToAncestor()); _overlayWindow.Left = rectWindow.Left;