aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-12-12 09:31:48 -0800
committerJoe Wilm <joe@jwilm.com>2016-12-12 09:31:48 -0800
commit1a1b740c38cfbadff4cd985ee925ac024627d2b9 (patch)
tree98f51ebedcc1abff0101da7747403b0d8aee698f /src/event.rs
parent4e9a307bed50fc02f101eb6cbfa4d39283dd6b8c (diff)
downloadalacritty-1a1b740c38cfbadff4cd985ee925ac024627d2b9.tar.gz
alacritty-1a1b740c38cfbadff4cd985ee925ac024627d2b9.zip
Remove need for Rc<RefCell<_>> usage
This adds a trait OnResize and a separate method handle_resize to the display. Instead of having a callback to receive resize events, a list of &mut OnResize are passed to this new method. Doing this allowed the only RefCell usage in the codebase to be removed :).
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/event.rs b/src/event.rs
index 4f28649e..b9a8551d 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -6,12 +6,12 @@ use serde_json as json;
use glutin;
-use window::Window;
-
+use config::Config;
+use display::OnResize;
use input;
use sync::FairMutex;
-use term::{self, Term};
-use config::Config;
+use term::{Term, SizeInfo};
+use window::Window;
/// The event processor
pub struct Processor<N> {
@@ -22,6 +22,15 @@ pub struct Processor<N> {
ref_test: bool,
}
+/// Notify that the terminal was resized
+///
+/// Currently this just forwards the notice to the input processor.
+impl<N> OnResize for Processor<N> {
+ fn on_resize(&mut self, size: &SizeInfo) {
+ self.input_processor.resize(size);
+ }
+}
+
impl<N: input::Notify> Processor<N> {
/// Create a new event processor
///
@@ -48,13 +57,6 @@ impl<N: input::Notify> Processor<N> {
}
}
- /// Notify that the terminal was resized
- ///
- /// Currently this just forwards the notice to the input processor.
- pub fn resize(&mut self, size_info: &term::SizeInfo) {
- self.input_processor.resize(size_info);
- }
-
fn handle_event(&mut self, event: glutin::Event, wakeup_request: &mut bool) {
match event {
glutin::Event::Closed => {