From 232fb5aaa4cd3193af571e23a221ff7e41385f91 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 27 Sep 2022 22:02:08 +0200 Subject: [PATCH] Disable screen redraw when there are no input events. --- profiler/src/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 1f93e3b6..cbf9437d 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -269,6 +269,27 @@ static void DrawContents() int display_w, display_h; bptr->NewFrame( display_w, display_h ); + + static int activeFrames = 3; + auto& inputQueue = ImGui::GetCurrentContext()->InputEventsQueue; + if( !inputQueue.empty() ) + { + for( auto& v : inputQueue ) + { + if( v.Type != ImGuiInputEventType_MouseViewport ) + { + activeFrames = 3; + break; + } + } + } + if( activeFrames == 0 ) + { + std::this_thread::sleep_for( std::chrono::milliseconds( 16 ) ); + return; + } + activeFrames--; + ImGui::NewFrame(); tracy::MouseFrame();