Docking: Fixed an issue leading to incorrect restoration of selected tab in dock nodes that don't carry the currently focused window. (#2304)

In TestSuite: see "docking_tab_focus_restore".
Remove old code ~ ed3c015f 8bac6d4 8cac70d8
+ Fix potential crash in IMGUI_DEBUG_LOG_DOCKING() path when using amended buttons.
This commit is contained in:
ocornut 2023-09-20 14:43:01 +02:00
parent 3ce6b06feb
commit 61acb34e32
2 changed files with 10 additions and 3 deletions

View File

@ -102,6 +102,8 @@ Other changes:
Docking+Viewports Branch:
- Docking: Fixed an issue leading to incorrect restoration of selected tab in dock nodes that
don't carry the currently focused window. (#2304)
- Docking: added ImGuiDockNodeFlags_NoUndocking. (#2999, #6823, #6780, #3492)
- Docking: renamed ImGuiDockNodeFlags_NoSplit to ImGuiDockNodeFlags_NoDockingSplit.
- Docking: renamed ImGuiDockNodeFlags_NoDockingInCentralNode to ImGuiDockNodeFlags_NoDockingOverCentralNode.

View File

@ -7635,8 +7635,9 @@ void ImGui::FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags)
window->LastFrameJustFocused = g.FrameCount;
// Select in dock node
if (dock_node && dock_node->TabBar)
dock_node->TabBar->SelectedTabId = dock_node->TabBar->NextSelectedTabId = window->TabId;
// For #2304 we avoid applying focus immediately before the tabbar is visible.
//if (dock_node && dock_node->TabBar)
// dock_node->TabBar->SelectedTabId = dock_node->TabBar->NextSelectedTabId = window->TabId;
// Bring to front
BringWindowToFocusFront(focus_front_window);
@ -16841,7 +16842,11 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
{
IMGUI_DEBUG_LOG_DOCKING("[docking] In node 0x%08X: %d new appearing tabs:%s\n", node->ID, tab_bar->Tabs.Size - tabs_unsorted_start, (tab_bar->Tabs.Size > tabs_unsorted_start + 1) ? " (will sort)" : "");
for (int tab_n = tabs_unsorted_start; tab_n < tab_bar->Tabs.Size; tab_n++)
IMGUI_DEBUG_LOG_DOCKING("[docking] - Tab '%s' Order %d\n", tab_bar->Tabs[tab_n].Window->Name, tab_bar->Tabs[tab_n].Window->DockOrder);
{
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
IMGUI_DEBUG_LOG_DOCKING("[docking] - Tab 0x%08X '%s' Order %d\n", tab->ID, TabBarGetTabName(tab_bar, tab), tab->Window ? tab->Window->DockOrder : -1);
}
IMGUI_DEBUG_LOG_DOCKING("[docking] SelectedTabId = 0x%08X, NavWindow->TabId = 0x%08X\n", node->SelectedTabId, g.NavWindow ? g.NavWindow->TabId : -1);
if (tab_bar->Tabs.Size > tabs_unsorted_start + 1)
ImQsort(tab_bar->Tabs.Data + tabs_unsorted_start, tab_bar->Tabs.Size - tabs_unsorted_start, sizeof(ImGuiTabItem), TabItemComparerByDockOrder);
}