#include "Platform/Win32/EditorWindowManager.h" #include "State/EditorContext.h" #include "Platform/Win32/EditorWindow.h" namespace XCEngine::UI::Editor::App { void EditorWindowManager::ProcessPendingDetachRequests() { if (m_globalTabDragSession.active) { return; } std::vector windowsToProcess = {}; for (const std::unique_ptr& window : m_windows) { if (window != nullptr && window->GetHwnd() != nullptr) { windowsToProcess.push_back(window.get()); } } for (EditorWindow* window : windowsToProcess) { if (window != nullptr) { TryProcessDetachRequest(*window); } } } bool EditorWindowManager::TryProcessDetachRequest(EditorWindow& sourceWindow) { const std::optional pending = sourceWindow.ConsumeDetachRequest(); if (!pending.has_value()) { return false; } const std::string sourceWindowId(sourceWindow.GetWindowId()); UIEditorWindowWorkspaceController windowWorkspaceController = BuildLiveWindowWorkspaceController(sourceWindowId); const UIEditorWindowWorkspaceOperationResult result = windowWorkspaceController.DetachPanelToNewWindow( sourceWindowId, pending->nodeId, pending->panelId); if (result.status != UIEditorWindowWorkspaceOperationStatus::Changed) { LogRuntimeTrace("detach", "detach request rejected: " + result.message); return false; } if (!SynchronizeWindowsFromController( windowWorkspaceController, result.targetWindowId, pending->screenPoint)) { LogRuntimeTrace("detach", "failed to synchronize detached window state"); return false; } if (EditorWindow* detachedWindow = FindWindow(result.targetWindowId); detachedWindow != nullptr && detachedWindow->GetHwnd() != nullptr) { SetForegroundWindow(detachedWindow->GetHwnd()); } LogRuntimeTrace( "detach", "detached panel '" + pending->panelId + "' from window '" + sourceWindowId + "' to window '" + result.targetWindowId + "'"); return true; } } // namespace XCEngine::UI::Editor::App