From 70f48c3ef7dde34546b6d646818333505d0e4777 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 17 Nov 2021 22:29:05 -0500 Subject: refactor --- src/action.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/action.rs') diff --git a/src/action.rs b/src/action.rs index c7f437c..22f088e 100644 --- a/src/action.rs +++ b/src/action.rs @@ -4,6 +4,7 @@ pub enum Action { ForceRedraw, Run(String), UpdateFocus(crate::state::Focus), + ToggleFullscreen(usize), Resize((u16, u16)), Quit, } @@ -37,6 +38,7 @@ struct Pending { force_redraw: Option<()>, run: std::collections::VecDeque, focus: Option, + fullscreen: std::collections::VecDeque, size: Option<(u16, u16)>, done: bool, } @@ -52,6 +54,7 @@ impl Pending { || self.force_redraw.is_some() || !self.run.is_empty() || self.focus.is_some() + || !self.fullscreen.is_empty() || self.size.is_some() } @@ -65,6 +68,11 @@ impl Pending { if self.focus.is_some() { return Some(Action::UpdateFocus(self.focus.take().unwrap())); } + if !self.fullscreen.is_empty() { + return Some(Action::ToggleFullscreen( + self.fullscreen.pop_front().unwrap(), + )); + } if self.force_redraw.is_some() { self.force_redraw.take(); self.render.take(); @@ -86,6 +94,9 @@ impl Pending { Some(Action::ForceRedraw) => self.force_redraw = Some(()), Some(Action::Run(cmd)) => self.run.push_back(cmd.to_string()), Some(Action::UpdateFocus(focus)) => self.focus = Some(*focus), + Some(Action::ToggleFullscreen(idx)) => { + self.fullscreen.push_back(*idx); + } Some(Action::Resize(size)) => self.size = Some(*size), Some(Action::Quit) | None => self.done = true, } -- cgit v1.2.3-54-g00ecf