1
0
mirror of synced 2024-11-28 01:20:51 +01:00

impr: Even less laggy UI

This commit is contained in:
WerWolv 2023-12-27 21:23:54 +01:00
parent 0462dab170
commit 99ba47a554

View File

@ -177,7 +177,7 @@ namespace hex {
static i32 lockTimeout = 0;
if (!shouldLongSleep) {
lockTimeout = ImHexApi::System::getTargetFPS() / 2;
lockTimeout = (1.0 / m_lastFrameTime);
} else if (lockTimeout > 0) {
lockTimeout -= 1;
}
@ -1043,6 +1043,8 @@ namespace hex {
if (auto g = ImGui::GetCurrentContext(); g == nullptr || g->WithinFrameScope) return;
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->m_unlockFrameRate = true;
win->frameBegin();
win->frame();
win->frameEnd();
@ -1056,11 +1058,20 @@ namespace hex {
if (auto g = ImGui::GetCurrentContext(); g == nullptr || g->WithinFrameScope) return;
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->m_unlockFrameRate = true;
win->frameBegin();
win->frame();
win->frameEnd();
});
glfwSetCursorPosCallback(m_window, [](GLFWwindow *window, double, double) {
if (auto g = ImGui::GetCurrentContext(); g == nullptr || g->WithinFrameScope) return;
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->m_unlockFrameRate = true;
});
#if !defined(OS_WEB)
// Register key press callback
glfwSetKeyCallback(m_window, [](GLFWwindow *window, int key, int scanCode, int action, int mods) {
@ -1088,6 +1099,7 @@ namespace hex {
key != GLFW_KEY_LEFT_SUPER && key != GLFW_KEY_RIGHT_SUPER
) {
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->m_unlockFrameRate = true;
win->m_pressedKeys.push_back(key);
}
}