Notify only Palette changes in iced_debug

This commit is contained in:
Héctor Ramón Jiménez 2024-02-27 15:38:47 +01:00
parent c856d2b513
commit 26d49be1b2
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -57,7 +57,13 @@ mod internal {
use std::sync::{Mutex, MutexGuard}; use std::sync::{Mutex, MutexGuard};
pub fn theme_changed(palette: theme::Palette) { pub fn theme_changed(palette: theme::Palette) {
lock().sentinel.report_theme_change(palette); let mut debug = lock();
if debug.last_palette.as_ref() != Some(&palette) {
debug.sentinel.report_theme_change(palette);
debug.last_palette = Some(palette);
}
} }
pub fn boot_time() -> Timer { pub fn boot_time() -> Timer {
@ -117,12 +123,14 @@ mod internal {
#[derive(Debug)] #[derive(Debug)]
struct Debug { struct Debug {
sentinel: Client, sentinel: Client,
last_palette: Option<theme::Palette>,
} }
fn lock() -> MutexGuard<'static, Debug> { fn lock() -> MutexGuard<'static, Debug> {
static DEBUG: Lazy<Mutex<Debug>> = Lazy::new(|| { static DEBUG: Lazy<Mutex<Debug>> = Lazy::new(|| {
Mutex::new(Debug { Mutex::new(Debug {
sentinel: client::connect(), sentinel: client::connect(),
last_palette: None,
}) })
}); });