diff --git a/backends/imgui_impl_win32.cpp b/backends/imgui_impl_win32.cpp index b14ae1abb..8cc0d9a11 100644 --- a/backends/imgui_impl_win32.cpp +++ b/backends/imgui_impl_win32.cpp @@ -1067,10 +1067,20 @@ static void ImGui_ImplWin32_ShowWindow(ImGuiViewport* viewport) { ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData; IM_ASSERT(vd->Hwnd != 0); + + // ShowParent() also brings parent to front, which is not always desirable, + // so we temporarily disable parenting. (#7354) + if (vd->HwndParent != NULL) + ::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)nullptr); + if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing) ::ShowWindow(vd->Hwnd, SW_SHOWNA); else ::ShowWindow(vd->Hwnd, SW_SHOW); + + // Restore + if (vd->HwndParent != NULL) + ::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)vd->HwndParent); } static void ImGui_ImplWin32_UpdateWindow(ImGuiViewport* viewport) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 2b24d0a6b..bdce7ab6a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -46,6 +46,11 @@ Other changes: it would generally manifest when fast moving the mouse bottom to top in a sub-menu. (#7325, #7287, #7063) +Docking+Viewports Branch: + +- Backends: Win32: made it so that an appearing viewport showing up doesn't bring + its parent to front. (#7354) + ----------------------------------------------------------------------- VERSION 1.90.4 (Released 2024-02-22)