diff --git a/external/solanaceae_plugin b/external/solanaceae_plugin index 96bab020..75e7c5e3 160000 --- a/external/solanaceae_plugin +++ b/external/solanaceae_plugin @@ -1 +1 @@ -Subproject commit 96bab0200f5b13671756abe7e3132ed78aaa2a40 +Subproject commit 75e7c5e3c77ecd5e03ad0a1429e3a5fc6d067408 diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index 31547d4e..7c6e8076 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -51,7 +51,7 @@ ChatGui4::ChatGui4( ) : _conf(conf), _rmm(rmm), _cr(cr), _tal(_cr), _contact_tc(_tal, tu), _msg_tc(_mil, tu), _sip(tu) { } -void ChatGui4::render(void) { +void ChatGui4::render(float time_delta) { if (!_cr.storage().empty()) { // handle force-reloads for avatars std::vector to_purge; _cr.view().each([&to_purge](const Contact3 c) { @@ -66,7 +66,7 @@ void ChatGui4::render(void) { _msg_tc.update(); _fss.render(); - _sip.render(); + _sip.render(time_delta); const ImGuiViewport* viewport = ImGui::GetMainViewport(); ImGui::SetNextWindowPos(viewport->WorkPos); diff --git a/src/chat_gui4.hpp b/src/chat_gui4.hpp index df7d3754..2ae8a030 100644 --- a/src/chat_gui4.hpp +++ b/src/chat_gui4.hpp @@ -46,7 +46,7 @@ class ChatGui4 { ); public: - void render(void); + void render(float time_delta); public: bool any_unread {false}; diff --git a/src/main_screen.cpp b/src/main_screen.cpp index f2ff8693..a15fc487 100644 --- a/src/main_screen.cpp +++ b/src/main_screen.cpp @@ -140,13 +140,7 @@ bool MainScreen::handleEvent(SDL_Event& e) { return false; } -Screen* MainScreen::render(float time_delta, bool& quit) { - quit = !tc.iterate(); - - tcm.iterate(time_delta); - - tam.iterate(); - +Screen* MainScreen::render(float time_delta, bool&) { // HACK: render the tomato main window first, with proper flags set. // flags need to be set the first time begin() is called. // and plugins are run before the main cg is run. @@ -164,15 +158,12 @@ Screen* MainScreen::render(float time_delta, bool& quit) { ImGui::End(); } - pm.tick(time_delta); - tdch.tick(time_delta); + const float pm_interval = pm.render(time_delta); // render - mts.iterate(); - - cg.render(); - sw.render(); - tuiu.render(); - tdch.render(); + cg.render(time_delta); // render + sw.render(); // render + tuiu.render(); // render + tdch.render(); // render { // main window menubar injection if (ImGui::Begin("tomato")) { @@ -189,7 +180,7 @@ Screen* MainScreen::render(float time_delta, bool& quit) { const auto targets = "normal\0powersave\0"; ImGui::SetNextItemWidth(ImGui::GetFontSize()*10); ImGui::Combo("compute mode", &_compute_perf_mode, targets, 4); - ImGui::SetItemTooltip("Limiting compute can slow down things filetransfers."); + ImGui::SetItemTooltip("Limiting compute can slow down things like filetransfers!"); } ImGui::EndMenu(); @@ -207,22 +198,40 @@ Screen* MainScreen::render(float time_delta, bool& quit) { } if ( - _fps_perf_mode >= 1 || // TODO: magic + _fps_perf_mode > 1 // TODO: magic + ) { + // powersave forces 250ms + _render_interval = 1.f/4.f; + } else if ( + _fps_perf_mode == 1 || // TODO: magic _window_hidden ) { - _render_interval = 1.f/4.f; + _render_interval = std::min(1.f/4.f, pm_interval); } else { - _render_interval = 1.f/60.f; + _render_interval = std::min(1.f/60.f, pm_interval); } return nullptr; } Screen* MainScreen::tick(float time_delta, bool& quit) { + quit = !tc.iterate(); // compute + + tcm.iterate(time_delta); // compute + + tam.iterate(); // compute + + const float pm_interval = pm.tick(time_delta); // compute + + tdch.tick(time_delta); // compute + + mts.iterate(); // compute + _min_tick_interval = std::max( std::min( tc.toxIterationInterval()/1000.f, - 0.03f // HACK: 30ms upper bound, should be the same as tox but will change + pm_interval + //0.03f // HACK: 30ms upper bound, should be the same as tox but will change ), (_compute_perf_mode == 0 ? 0.001f : 0.1f) // in powersave fix the lowerbound to 100ms ); diff --git a/src/send_image_popup.cpp b/src/send_image_popup.cpp index 17069573..00ff6864 100644 --- a/src/send_image_popup.cpp +++ b/src/send_image_popup.cpp @@ -158,7 +158,7 @@ void SendImagePopup::sendMemory( } -void SendImagePopup::render(void) { +void SendImagePopup::render(float time_delta) { if (_open_popup) { _open_popup = false; ImGui::OpenPopup("send image##SendImagePopup"); @@ -171,7 +171,7 @@ void SendImagePopup::render(void) { preview_image.doAnimation(getNowMS()); - time += 1.f/60.f; // TODO: actual delay + time += time_delta; time = fmod(time, 1.f); // fract() //ImGui::Text("send file....\n......"); diff --git a/src/send_image_popup.hpp b/src/send_image_popup.hpp index d334d0b5..2e5f0008 100644 --- a/src/send_image_popup.hpp +++ b/src/send_image_popup.hpp @@ -71,6 +71,6 @@ struct SendImagePopup { // from file_path // call this each frame - void render(void); + void render(float time_delta); };