mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 23:36:11 +00:00
perf(gui): cut hidden CPU with a busy daemon
Coalesce daemon events to one status refresh per 10 s while hidden (1 s visible), skip log/config reads and the UI-thread hand-off while hidden, and render tray pixmaps once per state. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7ccc8a497a
commit
5aeb7b2077
4 files changed
+36
-23
No files matched your search
@@ -5,7 +5,7 @@ use crate::model::{Aggregate, TrayState};
|
||||
use ksni::blocking::{Handle, TrayMethods};
|
||||
use ksni::menu::StandardItem;
|
||||
use ksni::{Icon, MenuItem, Status, ToolTip};
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Action {
|
||||
@@ -188,8 +188,12 @@ pub fn render(s: TrayState, size: u32) -> Icon {
|
||||
}
|
||||
}
|
||||
|
||||
/// Rendered once per state: the tray asks for the pixmaps on every property read.
|
||||
fn icons(s: TrayState) -> Vec<Icon> {
|
||||
vec![render(s, 22), render(s, 32), render(s, 64)]
|
||||
static CACHE: [OnceLock<Vec<Icon>>; 5] = [const { OnceLock::new() }; 5];
|
||||
CACHE[s as usize]
|
||||
.get_or_init(|| vec![render(s, 22), render(s, 32), render(s, 64)])
|
||||
.clone()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in new issue
Block a user