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

This commit is contained in:
ocornut
2025-06-18 17:01:49 +02:00
parent c2c38beec8
commit 2a8c75f3e6

View File

@@ -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;