fix(dock): address reviewer feedback on window tear-off

This commit is contained in:
2026-03-28 15:48:56 +09:00
parent 07274b6699
commit e83555498a
3 changed files with 19 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ namespace Ghost.Editor;
public partial class App : Application public partial class App : Application
{ {
private Window? _window; private Window? _window;
private readonly List<Window> _secondaryWindows = new();
internal static Window? Window internal static Window? Window
{ {
@@ -39,6 +40,15 @@ public partial class App : Application
} }
} }
internal static void AddSecondaryWindow(Window window)
{
if (Current is App app)
{
app._secondaryWindows.Add(window);
window.Closed += (s, e) => app._secondaryWindows.Remove(window);
}
}
internal IHost Host internal IHost Host
{ {
get; get;

View File

@@ -300,12 +300,15 @@ public sealed partial class DockLayout : Control
if (_sourceNode != null && _draggedItem != null) if (_sourceNode != null && _draggedItem != null)
{ {
// Remove from current tree // Remove from current tree
_sourceNode.Items.Remove(_draggedItem); if (_sourceNode.Items.Remove(_draggedItem))
DockMutationEngine.CleanupEmptyNodes(_sourceNode, Root); {
DockMutationEngine.CleanupEmptyNodes(_sourceNode);
// Create new window // Create new window and register it with App to prevent GC
var newWindow = new Ghost.Editor.View.Windows.DockWindow(_draggedItem); var newWindow = new Ghost.Editor.View.Windows.DockWindow(_draggedItem);
newWindow.Activate(); App.AddSecondaryWindow(newWindow);
newWindow.Activate();
}
ClearDragOperationState(); ClearDragOperationState();
} }

View File

@@ -3,7 +3,7 @@ using WinUIEx;
namespace Ghost.Editor.View.Windows; namespace Ghost.Editor.View.Windows;
public sealed partial class DockWindow : WindowEx internal sealed partial class DockWindow : WindowEx
{ {
public DockWindow(object initialTabContent) public DockWindow(object initialTabContent)
{ {
@@ -16,7 +16,5 @@ public sealed partial class DockWindow : WindowEx
rootGroup.AddChild(panel); rootGroup.AddChild(panel);
PART_DockLayout.Root = rootGroup; PART_DockLayout.Root = rootGroup;
// Optional: Titlebar setup etc.
} }
} }