aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs
index 3af417bd..de0faf7f 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -39,6 +39,7 @@ pub struct ActionContext<'a, N: 'a> {
pub received_count: &'a mut usize,
pub suppress_chars: &'a mut bool,
pub last_modifiers: &'a mut ModifiersState,
+ pub window_changes: &'a mut WindowChanges,
}
impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
@@ -138,6 +139,33 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn last_modifiers(&mut self) -> &mut ModifiersState {
&mut self.last_modifiers
}
+
+ #[inline]
+ fn hide_window(&mut self) {
+ self.window_changes.hide = true;
+ }
+}
+
+/// The ActionContext can't really have direct access to the Window
+/// with the current design. Event handlers that want to change the
+/// window must set these flags instead. The processor will trigger
+/// the actual changes.
+pub struct WindowChanges {
+ pub hide: bool,
+}
+
+impl WindowChanges {
+ fn clear(&mut self) {
+ self.hide = false;
+ }
+}
+
+impl Default for WindowChanges {
+ fn default() -> WindowChanges {
+ WindowChanges {
+ hide: false,
+ }
+ }
}
pub enum ClickState {
@@ -204,6 +232,7 @@ pub struct Processor<N> {
suppress_chars: bool,
last_modifiers: ModifiersState,
pending_events: Vec<Event>,
+ window_changes: WindowChanges,
}
/// Notify that the terminal was resized
@@ -246,6 +275,7 @@ impl<N: Notify> Processor<N> {
suppress_chars: false,
last_modifiers: Default::default(),
pending_events: Vec::with_capacity(4),
+ window_changes: Default::default(),
}
}
@@ -398,6 +428,7 @@ impl<N: Notify> Processor<N> {
received_count: &mut self.received_count,
suppress_chars: &mut self.suppress_chars,
last_modifiers: &mut self.last_modifiers,
+ window_changes: &mut self.window_changes,
};
processor = input::Processor {
@@ -442,6 +473,11 @@ impl<N: Notify> Processor<N> {
window.is_focused = window_is_focused;
}
+ if self.window_changes.hide {
+ window.hide();
+ }
+
+ self.window_changes.clear();
self.wait_for_event = !terminal.dirty;
terminal