From: Stephen Seo Date: Wed, 15 Dec 2021 05:36:56 +0000 (+0900) Subject: WIP only update display if dirty_flag is set X-Git-Tag: 0.2.0~15 X-Git-Url: https://git.seodisparate.com/stephenseo/LD54_Box_Survival?a=commitdiff_plain;h=796ad86f1965f3dde7c60bb1faeed40b06d8bd74;p=mpd_info_screen WIP only update display if dirty_flag is set --- diff --git a/src/display.rs b/src/display.rs index be9aa47..d2b890e 100644 --- a/src/display.rs +++ b/src/display.rs @@ -88,11 +88,19 @@ impl EventHandler for MPDDisplay { if self.is_valid && self.is_initialized && self.poll_instant.elapsed() > POLL_TIME { self.poll_instant = Instant::now(); - self.shared = MPDHandler::get_current_song_info(self.mpd_handler.clone().unwrap()) - .map_or(None, |f| Some(f)); - if let Some(shared) = &self.shared { - if self.notice_text.contents() != shared.error_text { - self.notice_text = Text::new(TextFragment::new(shared.error_text.clone())); + if !self.dirty_flag.is_none() + && self + .dirty_flag + .as_ref() + .unwrap() + .swap(false, std::sync::atomic::Ordering::Relaxed) + { + self.shared = MPDHandler::get_current_song_info(self.mpd_handler.clone().unwrap()) + .map_or(None, |f| Some(f)); + if let Some(shared) = &self.shared { + if self.notice_text.contents() != shared.error_text { + self.notice_text = Text::new(TextFragment::new(shared.error_text.clone())); + } } } }