Browse Source

Backends: Win32: made it so that an appearing viewport showing up doesn't bring its parent viewport to front. (#7354)

ocornut 1 year ago
parent
commit
4e8c43f6b7
2 changed files with 15 additions and 0 deletions
  1. 10 0
      backends/imgui_impl_win32.cpp
  2. 5 0
      docs/CHANGELOG.txt

+ 10 - 0
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)

+ 5 - 0
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)