Fix #508 warnings

This commit is contained in:
halx99 2021-09-26 21:52:36 +08:00
parent abca030baf
commit 7c940546a5
1 changed files with 33 additions and 30 deletions

View File

@ -133,7 +133,8 @@ struct ImGui_ImplAdxe_Data
// FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context. // FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context.
static ImGui_ImplAdxe_Data* ImGui_ImplAdxe_GetBackendData() static ImGui_ImplAdxe_Data* ImGui_ImplAdxe_GetBackendData()
{ {
return ImGui::GetCurrentContext() ? reinterpret_cast<ImGui_ImplAdxe_Data*>(ImGui::GetIO().BackendPlatformUserData) : nullptr; return ImGui::GetCurrentContext() ? reinterpret_cast<ImGui_ImplAdxe_Data*>(ImGui::GetIO().BackendPlatformUserData)
: nullptr;
} }
// Forward Declarations // Forward Declarations
@ -1081,6 +1082,8 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)(); ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)();
viewport->PlatformUserData = vd; viewport->PlatformUserData = vd;
const bool multi_viewport_enabled = !!(ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable);
// GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED // GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED
// With GLFW 3.3, the hint GLFW_FOCUS_ON_SHOW fixes this problem // With GLFW 3.3, the hint GLFW_FOCUS_ON_SHOW fixes this problem
glfwWindowHint(GLFW_VISIBLE, false); glfwWindowHint(GLFW_VISIBLE, false);
@ -1092,11 +1095,9 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
#if GLFW_HAS_WINDOW_TOPMOST #if GLFW_HAS_WINDOW_TOPMOST
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false); glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false);
#endif #endif
#if CC_IMGUI_ENABLE_MULTI_VIEWPORT
GLFWwindow* share_window = bd->Window; GLFWwindow* share_window = multi_viewport_enabled ? bd->Window : nullptr;
#else
GLFWwindow* share_window = nullptr;
#endif
vd->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", nullptr, share_window); vd->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", nullptr, share_window);
vd->WindowOwned = true; vd->WindowOwned = true;
viewport->PlatformHandle = (void*)vd->Window; viewport->PlatformHandle = (void*)vd->Window;
@ -1115,13 +1116,13 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
glfwSetWindowCloseCallback(vd->Window, ImGui_ImplGlfw_WindowCloseCallback); glfwSetWindowCloseCallback(vd->Window, ImGui_ImplGlfw_WindowCloseCallback);
glfwSetWindowPosCallback(vd->Window, ImGui_ImplGlfw_WindowPosCallback); glfwSetWindowPosCallback(vd->Window, ImGui_ImplGlfw_WindowPosCallback);
glfwSetWindowSizeCallback(vd->Window, ImGui_ImplGlfw_WindowSizeCallback); glfwSetWindowSizeCallback(vd->Window, ImGui_ImplGlfw_WindowSizeCallback);
#if CC_IMGUI_ENABLE_MULTI_VIEWPORT if (multi_viewport_enabled)
// TODO: metal {
const auto window = vd->Window; const auto window = vd->Window;
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
glfwSwapInterval(0); glfwSwapInterval(0);
AddRendererCommand([=]() { glfwMakeContextCurrent(window); }); AddRendererCommand([=]() { glfwMakeContextCurrent(window); });
#endif }
} }
static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport) static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
@ -1291,25 +1292,27 @@ static void ImGui_ImplGlfw_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
#endif #endif
static void ImGui_ImplGlfw_RenderWindow(ImGuiViewport* viewport, void*) static void ImGui_ImplGlfw_RenderWindow(ImGuiViewport* viewport, void*)
{
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{ {
ImGui_ImplGlfw_ViewportData* vd = IMGUI_GLFW_VD(viewport); ImGui_ImplGlfw_ViewportData* vd = IMGUI_GLFW_VD(viewport);
#if CC_IMGUI_ENABLE_MULTI_VIEWPORT
const auto window = vd->Window; const auto window = vd->Window;
AddRendererCommand([=]() { glfwMakeContextCurrent(window); }); AddRendererCommand([=]() { glfwMakeContextCurrent(window); });
#endif }
} }
static void ImGui_ImplGlfw_SwapBuffers(ImGuiViewport* viewport, void*) static void ImGui_ImplGlfw_SwapBuffers(ImGuiViewport* viewport, void*)
{
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{ {
ImGui_ImplGlfw_ViewportData* vd = IMGUI_GLFW_VD(viewport); ImGui_ImplGlfw_ViewportData* vd = IMGUI_GLFW_VD(viewport);
#if CC_IMGUI_ENABLE_MULTI_VIEWPORT
const auto window = vd->Window; const auto window = vd->Window;
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
AddRendererCommand([=]() { AddRendererCommand([=]() {
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
glfwSwapBuffers(window); glfwSwapBuffers(window);
}); });
#endif }
} }
// clang-format off // clang-format off