From 152a95cb403c648dd7fef6c520a34f176a436362 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 1 Dec 2022 18:33:48 -0500 Subject: [PATCH] GUI: fix inertial scroll when power saving is on --- extern/imgui_patched/imgui.cpp | 3 +++ extern/imgui_patched/imgui.h | 1 + src/gui/gui.cpp | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/extern/imgui_patched/imgui.cpp b/extern/imgui_patched/imgui.cpp index 07928bb39..a0298a3fb 100644 --- a/extern/imgui_patched/imgui.cpp +++ b/extern/imgui_patched/imgui.cpp @@ -4469,6 +4469,7 @@ void ImGui::NewFrame() g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame)); g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX; + g.IO.IsSomethingHappening = false; UpdateViewportsNewFrame(); @@ -6961,12 +6962,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if (fabs(window->InertialScrollSpeed.x)>0.1f) { window->Scroll.x=window->Scroll.x+window->InertialScrollSpeed.x; window->InertialScrollSpeed.x*=0.95f; + g.IO.IsSomethingHappening = true; } else { window->InertialScrollSpeed.x=0.0f; } if (fabs(window->InertialScrollSpeed.y)>0.1f) { window->Scroll.y=window->Scroll.y+window->InertialScrollSpeed.y; window->InertialScrollSpeed.y*=0.95f; + g.IO.IsSomethingHappening = true; } else { window->InertialScrollSpeed.y=0.0f; } diff --git a/extern/imgui_patched/imgui.h b/extern/imgui_patched/imgui.h index afc84ebae..5359672e1 100644 --- a/extern/imgui_patched/imgui.h +++ b/extern/imgui_patched/imgui.h @@ -2096,6 +2096,7 @@ struct ImGuiIO bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving! + bool IsSomethingHappening; // This is set to true when inertial scrolling is happening. bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag. bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events). float Framerate; // Rough estimate of application framerate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames. diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index fecd377b3..ca806a3df 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3171,6 +3171,11 @@ bool FurnaceGUI::loop() { if (wantCaptureKeyboard) { WAKE_UP; } + + if (ImGui::GetIO().IsSomethingHappening) { + WAKE_UP; + } + if (ImGui::GetIO().MouseDown[0] || ImGui::GetIO().MouseDown[1] || ImGui::GetIO().MouseDown[2] || ImGui::GetIO().MouseDown[3] || ImGui::GetIO().MouseDown[4]) { WAKE_UP; }