diff --git a/src/layout.rs b/src/layout.rs index 65b63ff..d0b3091 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -55,8 +55,8 @@ impl Layout { } } - pub fn update(&mut self, display_hours: bool) { - if self.force_recalc.swap(false, Ordering::Relaxed) { + pub fn update(&mut self, display_hours: bool, force: bool) { + if self.force_recalc.swap(false, Ordering::Relaxed) || force { let (width, height) = termion::terminal_size() .expect("Could not read terminal size!"); self.width = width; diff --git a/src/main.rs b/src/main.rs index 6a30628..a2503e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -231,12 +231,10 @@ fn main() { layout.force_recalc.store(true, Ordering::Relaxed); } - // Force recalculation of layout if we start displaying hours. - if clock.elapsed == 3600 { - layout.force_recalc.store(true, Ordering::Relaxed); - } // Update window size information and calculate the clock position. - layout.update(clock.elapsed >= 3600); + // Also enforce recalculation of layout if we start displaying + // hours. + layout.update(clock.elapsed >= 3600, clock.elapsed == 3600); // Check for exceeded alarms. if alarm_roster.check(&mut clock, &layout, &mut countdown) {