From 4a4e921eb1c265ada48c14be4a7ff9b970a9b883 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Fri, 17 Apr 2026 23:18:05 +0800 Subject: [PATCH] new_editor: fix detached multi-tab tab dragging --- .../Platform/Win32/WindowManager/TabDrag.cpp | 87 +++++++++++-------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/new_editor/app/Platform/Win32/WindowManager/TabDrag.cpp b/new_editor/app/Platform/Win32/WindowManager/TabDrag.cpp index c68b2b0f..858f0802 100644 --- a/new_editor/app/Platform/Win32/WindowManager/TabDrag.cpp +++ b/new_editor/app/Platform/Win32/WindowManager/TabDrag.cpp @@ -466,52 +466,65 @@ bool EditorWindowWorkspaceCoordinator::TryStartGlobalTabDrag( request.screenPoint, dragHotspot); - if (sourceWindow.IsPrimary()) { - UIEditorWindowWorkspaceController windowWorkspaceController = - BuildLiveWindowWorkspaceController(sourceWindow.GetWindowId()); - const UIEditorWindowWorkspaceOperationResult result = - windowWorkspaceController.DetachPanelToNewWindow( - sourceWindow.GetWindowId(), - request.nodeId, - request.panelId); - if (result.status != UIEditorWindowWorkspaceOperationStatus::Changed) { + const auto tryStartDetachedPanelGlobalDrag = + [this, &request, &dragHotspot]( + UIEditorWindowWorkspaceController& windowWorkspaceController, + const UIEditorWindowWorkspaceOperationResult& result) { + if (!SynchronizeWindowsFromController( + windowWorkspaceController, + result.targetWindowId, + request.screenPoint)) { + LogRuntimeTrace("drag", "failed to synchronize detached drag window state"); + return false; + } + + EditorWindow* detachedWindow = m_hostRuntime.FindWindow(result.targetWindowId); + if (!IsLiveInteractiveWindow(detachedWindow)) { + LogRuntimeTrace("drag", "detached drag window was not created."); + return false; + } + + BeginGlobalTabDragSession( + detachedWindow->GetWindowId(), + detachedWindow->GetWorkspaceController().GetWorkspace().root.nodeId, + request.panelId, + request.screenPoint, + dragHotspot); + UpdateGlobalTabDragOwnerWindowPosition(); + SetCapture(detachedWindow->GetHwnd()); + SetForegroundWindow(detachedWindow->GetHwnd()); LogRuntimeTrace( "drag", - "failed to start global tab drag from primary window: " + result.message); - return false; - } + "started global tab drag by detaching panel '" + request.panelId + + "' into window '" + std::string(detachedWindow->GetWindowId()) + "'"); + return true; + }; - if (!SynchronizeWindowsFromController( - windowWorkspaceController, - result.targetWindowId, - request.screenPoint)) { - LogRuntimeTrace("drag", "failed to synchronize detached drag window state"); - return false; - } + UIEditorWindowWorkspaceController windowWorkspaceController = + BuildLiveWindowWorkspaceController(sourceWindow.GetWindowId()); + const UIEditorWindowWorkspaceOperationResult result = + windowWorkspaceController.DetachPanelToNewWindow( + sourceWindow.GetWindowId(), + request.nodeId, + request.panelId); + if (result.status == UIEditorWindowWorkspaceOperationStatus::Changed) { + return tryStartDetachedPanelGlobalDrag(windowWorkspaceController, result); + } - EditorWindow* detachedWindow = m_hostRuntime.FindWindow(result.targetWindowId); - if (!IsLiveInteractiveWindow(detachedWindow)) { - LogRuntimeTrace("drag", "detached drag window was not created."); - return false; - } - - BeginGlobalTabDragSession( - detachedWindow->GetWindowId(), - detachedWindow->GetWorkspaceController().GetWorkspace().root.nodeId, - request.panelId, - request.screenPoint, - dragHotspot); - UpdateGlobalTabDragOwnerWindowPosition(); - SetCapture(detachedWindow->GetHwnd()); - SetForegroundWindow(detachedWindow->GetHwnd()); + if (sourceWindow.IsPrimary()) { LogRuntimeTrace( "drag", - "started global tab drag by detaching panel '" + request.panelId + - "' into window '" + std::string(detachedWindow->GetWindowId()) + "'"); - return true; + "failed to start global tab drag from primary window: " + result.message); + return false; } sourceWindow.ResetInteractionState(); + if (result.status != UIEditorWindowWorkspaceOperationStatus::NoOp) { + LogRuntimeTrace( + "drag", + "failed to start global tab drag from detached window: " + result.message); + return false; + } if (!CanStartGlobalTabDragFromWindow(sourceWindow, request.nodeId, request.panelId)) { LogRuntimeTrace( "drag",