Refactored invocation of layout.update().
This commit is contained in:
parent
b69056c144
commit
3ad264aa7b
2 changed files with 5 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue