aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/event.rs b/src/event.rs
index f643c115..9a7d2e8e 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -135,6 +135,7 @@ pub struct Processor<N> {
mouse_bindings: Vec<MouseBinding>,
mouse_config: config::Mouse,
print_events: bool,
+ wait_for_event: bool,
notifier: N,
mouse: Mouse,
resize_tx: mpsc::Sender<(u32, u32)>,
@@ -170,6 +171,7 @@ impl<N: Notify> Processor<N> {
mouse_bindings: config.mouse_bindings().to_vec(),
mouse_config: config.mouse().to_owned(),
print_events: options.print_events,
+ wait_for_event: true,
notifier: notifier,
resize_tx: resize_tx,
ref_test: ref_test,
@@ -245,7 +247,8 @@ impl<N: Notify> Processor<N> {
}
}
- /// Process at least one event and handle any additional queued events.
+ /// Process events. When `wait_for_event` is set, this method is guaranteed
+ /// to process at least one event.
pub fn process_events<'a>(
&mut self,
term: &'a FairMutex<Term>,
@@ -276,28 +279,31 @@ impl<N: Notify> Processor<N> {
}
}
- match window.wait_events().next() {
- Some(event) => {
- terminal = term.lock();
- context = ActionContext {
- terminal: &mut terminal,
- notifier: &mut self.notifier,
- selection: &mut self.selection,
- mouse: &mut self.mouse,
- size_info: &self.size_info,
- };
-
- processor = input::Processor {
- ctx: context,
- mouse_config: &self.mouse_config,
- key_bindings: &self.key_bindings[..],
- mouse_bindings: &self.mouse_bindings[..],
- };
-
- process!(event);
- },
- // Glutin guarantees the WaitEventsIterator never returns None.
- None => unreachable!(),
+ let event = if self.wait_for_event {
+ window.wait_events().next()
+ } else {
+ None
+ };
+
+ terminal = term.lock();
+
+ context = ActionContext {
+ terminal: &mut terminal,
+ notifier: &mut self.notifier,
+ selection: &mut self.selection,
+ mouse: &mut self.mouse,
+ size_info: &self.size_info,
+ };
+
+ processor = input::Processor {
+ ctx: context,
+ mouse_config: &self.mouse_config,
+ key_bindings: &self.key_bindings[..],
+ mouse_bindings: &self.mouse_bindings[..]
+ };
+
+ if let Some(event) = event {
+ process!(event);
}
for event in window.poll_events() {
@@ -305,6 +311,8 @@ impl<N: Notify> Processor<N> {
}
}
+ self.wait_for_event = !terminal.dirty;
+
terminal
}