mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
SystemMonitor: Update stats/graph immediately on launch
Previously the stats was only updated once the first callback from refresh_timer fired. It now makes an early stats update on launch, so something will appear in the graphs.
This commit is contained in:
parent
f8ce211201
commit
badfe72b64
Notes:
sideshowbarker
2024-07-17 18:46:57 +09:00
Author: https://github.com/jbdk 🔰 Commit: https://github.com/SerenityOS/serenity/commit/badfe72b64 Pull-request: https://github.com/SerenityOS/serenity/pull/16811 Reviewed-by: https://github.com/linusg ✅
|
@ -312,21 +312,22 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
Config::write_i32("SystemMonitor"sv, "Monitor"sv, "Frequency"sv, frequency);
|
||||
}
|
||||
|
||||
auto& refresh_timer = window->add<Core::Timer>(
|
||||
frequency * 1000, [&] {
|
||||
// FIXME: remove the primitive re-toggling code once persistent model indices work.
|
||||
auto toggled_indices = process_table_view.selection().indices();
|
||||
toggled_indices.remove_all_matching([&](auto const& index) { return !process_table_view.is_toggled(index); });
|
||||
process_model->update();
|
||||
if (!process_table_view.selection().is_empty())
|
||||
process_table_view.selection().for_each_index([&](auto& selection) {
|
||||
if (toggled_indices.contains_slow(selection))
|
||||
process_table_view.expand_all_parents_of(selection);
|
||||
});
|
||||
auto update_stats = [&] {
|
||||
// FIXME: remove the primitive re-toggling code once persistent model indices work.
|
||||
auto toggled_indices = process_table_view.selection().indices();
|
||||
toggled_indices.remove_all_matching([&](auto const& index) { return !process_table_view.is_toggled(index); });
|
||||
process_model->update();
|
||||
if (!process_table_view.selection().is_empty())
|
||||
process_table_view.selection().for_each_index([&](auto& selection) {
|
||||
if (toggled_indices.contains_slow(selection))
|
||||
process_table_view.expand_all_parents_of(selection);
|
||||
});
|
||||
|
||||
if (auto* memory_stats_widget = SystemMonitor::MemoryStatsWidget::the())
|
||||
memory_stats_widget->refresh();
|
||||
});
|
||||
if (auto* memory_stats_widget = SystemMonitor::MemoryStatsWidget::the())
|
||||
memory_stats_widget->refresh();
|
||||
};
|
||||
update_stats();
|
||||
auto& refresh_timer = window->add<Core::Timer>(frequency * 1000, move(update_stats));
|
||||
|
||||
auto selected_id = [&](ProcessModel::Column column) -> pid_t {
|
||||
if (process_table_view.selection().is_empty())
|
||||
|
|
Loading…
Reference in a new issue