156156#define GLFW_HAS_GETKEYNAME (GLFW_VERSION_COMBINED >= 3200 ) // 3.2+ glfwGetKeyName()
157157#define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300 ) // 3.3+ glfwGetError()
158158#define GLFW_HAS_GETPLATFORM (GLFW_VERSION_COMBINED >= 3400 ) // 3.4+ glfwGetPlatform()
159+ #define GLFW_HAS_CREATECURSOR (GLFW_VERSION_COMBINED >= 3100 ) // 3.1+ glfwCreateCursor()
159160
160161// Map GLFWWindow* to ImGuiContext*.
161162// - Would be simpler if we could use glfwSetWindowUserPointer()/glfwGetWindowUserPointer(), but this is a single and shared resource.
@@ -182,7 +183,9 @@ struct ImGui_ImplGlfw_Data
182183 GlfwClientApi ClientApi;
183184 double Time;
184185 GLFWwindow* MouseWindow;
186+ #if GLFW_HAS_CREATECURSOR
185187 GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
188+ #endif
186189 ImVec2 LastValidMousePos;
187190 bool IsWayland;
188191 bool InstalledCallbacks;
@@ -679,6 +682,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
679682 // (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist,
680683 // GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting.
681684 // Missing cursors will return nullptr and our _UpdateMouseCursor() function will use the Arrow cursor instead.)
685+ #if GLFW_HAS_CREATECURSOR
682686 GLFWerrorfun prev_error_callback = glfwSetErrorCallback (nullptr );
683687 bd->MouseCursors [ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor (GLFW_ARROW_CURSOR);
684688 bd->MouseCursors [ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor (GLFW_IBEAM_CURSOR);
@@ -697,6 +701,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
697701 bd->MouseCursors [ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor (GLFW_ARROW_CURSOR);
698702#endif
699703 glfwSetErrorCallback (prev_error_callback);
704+ #endif
700705#if GLFW_HAS_GETERROR && !defined(__EMSCRIPTEN__) // Eat errors (see #5908)
701706 (void )glfwGetError (nullptr );
702707#endif
@@ -775,10 +780,10 @@ void ImGui_ImplGlfw_Shutdown()
775780 if (bd->CanvasSelector )
776781 emscripten_set_wheel_callback (bd->CanvasSelector , nullptr , false , nullptr );
777782#endif
778-
783+ # if GLFW_HAS_CREATECURSOR
779784 for (ImGuiMouseCursor cursor_n = 0 ; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
780785 glfwDestroyCursor (bd->MouseCursors [cursor_n]);
781-
786+ # endif
782787 // Windows: restore our WndProc hook
783788#ifdef _WIN32
784789 ImGuiViewport* main_viewport = ImGui::GetMainViewport ();
@@ -846,7 +851,9 @@ static void ImGui_ImplGlfw_UpdateMouseCursor()
846851 {
847852 // Show OS mouse cursor
848853 // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
854+ #if GLFW_HAS_CREATECURSOR
849855 glfwSetCursor (window, bd->MouseCursors [imgui_cursor] ? bd->MouseCursors [imgui_cursor] : bd->MouseCursors [ImGuiMouseCursor_Arrow]);
856+ #endif
850857 glfwSetInputMode (window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
851858 }
852859 }
0 commit comments