mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
Backends: GLFW: avoid repeated glfwSetCursor()/glfwSetInputMode() calls when unnecessary.
This commit is contained in:
parent
cf64b7fa72
commit
9a4fd69f6d
2 changed files with 16 additions and 3 deletions
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2025-12-10: Avoid repeated glfwSetCursor()/glfwSetInputMode() calls when unnecessary. Lowers overhead for very high framerates (e.g. 10k+ FPS).
|
||||||
// 2025-11-06: Lower minimum requirement to GLFW 3.0. Though a recent version e.g GLFW 3.4 is highly recommended.
|
// 2025-11-06: Lower minimum requirement to GLFW 3.0. Though a recent version e.g GLFW 3.4 is highly recommended.
|
||||||
// 2025-09-18: Call platform_io.ClearPlatformHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearPlatformHandlers() on shutdown.
|
||||||
// 2025-09-15: Content Scales are always reported as 1.0 on Wayland. FramebufferScale are always reported as 1.0 on X11. (#8920, #8921)
|
// 2025-09-15: Content Scales are always reported as 1.0 on Wayland. FramebufferScale are always reported as 1.0 on X11. (#8920, #8921)
|
||||||
|
|
@ -188,6 +189,7 @@ struct ImGui_ImplGlfw_Data
|
||||||
GLFWwindow* MouseWindow;
|
GLFWwindow* MouseWindow;
|
||||||
#if GLFW_HAS_CREATECURSOR
|
#if GLFW_HAS_CREATECURSOR
|
||||||
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
|
GLFWcursor* LastMouseCursor;
|
||||||
#endif
|
#endif
|
||||||
ImVec2 LastValidMousePos;
|
ImVec2 LastValidMousePos;
|
||||||
bool IsWayland;
|
bool IsWayland;
|
||||||
|
|
@ -849,15 +851,24 @@ static void ImGui_ImplGlfw_UpdateMouseCursor()
|
||||||
GLFWwindow* window = bd->Window;
|
GLFWwindow* window = bd->Window;
|
||||||
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
|
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
|
||||||
{
|
{
|
||||||
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
if (bd->LastMouseCursor != nullptr)
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
{
|
||||||
|
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
||||||
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||||
|
bd->LastMouseCursor = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Show OS mouse cursor
|
// Show OS mouse cursor
|
||||||
// FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
|
// FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
|
||||||
#if GLFW_HAS_CREATECURSOR
|
#if GLFW_HAS_CREATECURSOR
|
||||||
glfwSetCursor(window, bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow]);
|
GLFWcursor* cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
||||||
|
if (bd->LastMouseCursor != cursor)
|
||||||
|
{
|
||||||
|
glfwSetCursor(window, cursor);
|
||||||
|
bd->LastMouseCursor = cursor;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,8 @@ Other Changes:
|
||||||
non-ASCII values to io.AddInputCharacter(). (#9099)
|
non-ASCII values to io.AddInputCharacter(). (#9099)
|
||||||
- Debug Log: can output to debugger on Windows. (#5855)
|
- Debug Log: can output to debugger on Windows. (#5855)
|
||||||
- Backends:
|
- Backends:
|
||||||
|
- GLFW: Avoid repeated glfwSetCursor()/glfwSetInputMode() calls when unnecessary.
|
||||||
|
Lowers overhead for very high framerates (e.g. 10k+ FPS). [@maxliani]
|
||||||
- SDL_GPU3: macOS version can use MSL shaders in order to support macOS 10.14+
|
- SDL_GPU3: macOS version can use MSL shaders in order to support macOS 10.14+
|
||||||
(vs Metallib shaders requiring macOS 14+). Requires application calling
|
(vs Metallib shaders requiring macOS 14+). Requires application calling
|
||||||
SDL_CreateGPUDevice() with SDL_GPU_SHADERFORMAT_MSL. (#9076) [@Niminem]
|
SDL_CreateGPUDevice() with SDL_GPU_SHADERFORMAT_MSL. (#9076) [@Niminem]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue