@ -196,7 +196,7 @@ void ImGui_ImplGlfw_Shutdown()
g_ClientApi = GlfwClientApi_Unknown ;
}
static void ImGui_ImplGlfw_UpdateMouse ( )
static void ImGui_ImplGlfw_UpdateMouse PosAndButtons ( )
{
ImGuiIO & io = ImGui : : GetIO ( ) ;
const ImVec2 mouse_pos_backup = io . MousePos ;
@ -241,24 +241,30 @@ static void ImGui_ImplGlfw_UpdateMouse()
io . MouseHoveredViewport = viewport - > ID ;
# endif
}
}
static void ImGui_ImplGlfw_UpdateMouseCursor ( )
{
ImGuiIO & io = ImGui : : GetIO ( ) ;
if ( ( io . ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange ) | | glfwGetInputMode ( g_Window , GLFW_CURSOR ) = = GLFW_CURSOR_DISABLED )
return ;
// Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
// FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
if ( ( io . ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange ) = = 0 & & glfwGetInputMode ( g_Window , GLFW_CURSOR ) ! = GLFW_CURSOR_DISABLED )
ImGuiMouseCursor imgui_cursor = ImGui : : GetMouseCursor ( ) ;
ImGuiPlatformIO & platform_io = ImGui : : GetPlatformIO ( ) ;
for ( int n = 0 ; n < platform_io . Viewports . Size ; n + + )
{
ImGuiMouseCursor cursor = ImGui : : GetMouseCursor ( ) ;
for ( int n = 0 ; n < platform_io . Viewports . Size ; n + + )
GLFWwindow* window = ( GLFWwindow * ) platform_io . Viewports [ n ] - > PlatformHandle ;
if ( imgui_cursor = = ImGuiMouseCursor_None | | io . MouseDrawCursor )
{
GLFWwindow * window = ( GLFWwindow * ) platform_io . Viewports [ n ] - > PlatformHandle ;
if ( io . MouseDrawCursor | | cursor = = ImGuiMouseCursor_None )
{
glfwSetInputMode ( window , GLFW_CURSOR , GLFW_CURSOR_HIDDEN ) ;
}
else
{
glfwSetCursor ( window , g_MouseCursors [ cursor ] ? g_MouseCursors [ cursor ] : g_MouseCursors [ ImGuiMouseCursor_Arrow ] ) ;
glfwSetInputMode ( window , GLFW_CURSOR , GLFW_CURSOR_NORMAL ) ;
}
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
glfwSetInputMode ( window , GLFW_CURSOR , GLFW_CURSOR_HIDDEN ) ;
}
else
{
// Show OS mouse cursor
// FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
glfwSetCursor ( window , g_MouseCursors [ imgui_cursor ] ? g_MouseCursors [ imgui_cursor ] : g_MouseCursors [ ImGuiMouseCursor_Arrow ] ) ;
glfwSetInputMode ( window , GLFW_CURSOR , GLFW_CURSOR_NORMAL ) ;
}
}
}
@ -283,7 +289,8 @@ void ImGui_ImplGlfw_NewFrame()
io . DeltaTime = g_Time > 0.0 ? ( float ) ( current_time - g_Time ) : ( float ) ( 1.0f / 60.0f ) ;
g_Time = current_time ;
ImGui_ImplGlfw_UpdateMouse ( ) ;
ImGui_ImplGlfw_UpdateMousePosAndButtons ( ) ;
ImGui_ImplGlfw_UpdateMouseCursor ( ) ;
// Gamepad navigation mapping [BETA]
memset ( io . NavInputs , 0 , sizeof ( io . NavInputs ) ) ;