From ae4dde8255f8478154c0544b56f16520b89621e3 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 6 Jan 2025 20:34:00 +0100 Subject: [PATCH] impr: Unlock frame rate in more cases to make the UI feel more responsive --- main/gui/source/window/window.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 282734e9a..9cea79681 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -268,6 +268,24 @@ namespace hex { } m_lastFrameTime = glfwGetTime() - m_lastStartFrameTime; + + // Unlock frame rate if any mouse button is being held down to allow drag scrolling to be smooth + if (ImGui::IsAnyMouseDown()) + m_unlockFrameRate = true; + + // Unlock frame rate if any modifier key is held down since they don't generate key repeat events + if ( + ImGui::IsKeyPressed(ImGuiKey_LeftCtrl) || ImGui::IsKeyPressed(ImGuiKey_RightCtrl) || + ImGui::IsKeyPressed(ImGuiKey_LeftShift) || ImGui::IsKeyPressed(ImGuiKey_RightShift) || + ImGui::IsKeyPressed(ImGuiKey_LeftSuper) || ImGui::IsKeyPressed(ImGuiKey_RightSuper) || + ImGui::IsKeyPressed(ImGuiKey_LeftAlt) || ImGui::IsKeyPressed(ImGuiKey_RightAlt) + ) { + m_unlockFrameRate = true; + } + + // Unlock frame rate if there's more than one viewport since these don't call the glfw callbacks registered here + if (ImGui::GetPlatformIO().Viewports.size() > 1) + m_unlockFrameRate = true; } // Hide the window as soon as the render loop exits to make the window