Browse Source

Backends: GLFW: amend for multi-context support with multi-viewport. (#8676, #8239, #8069)

ocornut 1 month ago
parent
commit
2a8c75f3e6
1 changed files with 2 additions and 0 deletions
  1. 2 0
      backends/imgui_impl_glfw.cpp

+ 2 - 0
backends/imgui_impl_glfw.cpp

@@ -1213,6 +1213,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
     GLFWwindow* share_window = (bd->ClientApi == GlfwClientApi_OpenGL) ? bd->Window : nullptr;
     vd->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", nullptr, share_window);
     vd->WindowOwned = true;
+    ImGui_ImplGlfw_ContextMap_Add(vd->Window, bd->Context);
     viewport->PlatformHandle = (void*)vd->Window;
 #ifdef _WIN32
     viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window);
@@ -1257,6 +1258,7 @@ static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
                 if (bd->KeyOwnerWindows[i] == vd->Window)
                     ImGui_ImplGlfw_KeyCallback(vd->Window, i, 0, GLFW_RELEASE, 0); // Later params are only used for main viewport, on which this function is never called.
 
+            ImGui_ImplGlfw_ContextMap_Remove(vd->Window);
             glfwDestroyWindow(vd->Window);
         }
         vd->Window = nullptr;