aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs36
1 files changed, 13 insertions, 23 deletions
diff --git a/src/main.rs b/src/main.rs
index 7ae45787..c917fe43 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,9 +18,7 @@
#[macro_use]
extern crate alacritty;
-use std::cell::RefCell;
use std::error::Error;
-use std::rc::Rc;
use std::sync::Arc;
use alacritty::cli;
@@ -86,7 +84,7 @@ fn run(config: Config, options: cli::Options) -> Result<(), Box<Error>> {
// The pty forks a process to run the shell on the slave side of the
// pseudoterminal. A file descriptor for the master side is retained for
// reading/writing to the shell.
- let pty = tty::new(display.size());
+ let mut pty = tty::new(display.size());
// Create the pseudoterminal I/O loop
//
@@ -108,28 +106,13 @@ fn run(config: Config, options: cli::Options) -> Result<(), Box<Error>> {
// Event processor
//
// Need the Rc<RefCell<_>> here since a ref is shared in the resize callback
- let processor = Rc::new(RefCell::new(event::Processor::new(
+ let mut processor = event::Processor::new(
input::LoopNotifier(loop_tx),
terminal.clone(),
display.resize_channel(),
&config,
options.ref_test,
- )));
-
- // Configure the display resize callback
- let processor_ref = processor.clone();
- display.set_resize_callback(move |size| {
- // Resizing the pty lets the child processes know the window changed
- // size.
- pty.resize(size);
-
- // It's a bit funny that the event processor is in this callback since
- // on some platforms it's the first to be aware of a resize event. It
- // appears here since resizes are processed out-of-band from when the
- // events arrive. This way, the processor state is updated at the same
- // time as the rest of the system.
- processor_ref.borrow_mut().resize(size)
- });
+ );
// Create a config monitor when config was loaded from path
//
@@ -144,20 +127,27 @@ fn run(config: Config, options: cli::Options) -> Result<(), Box<Error>> {
// Main display loop
loop {
// Process input and window events
- let wakeup_request = processor.borrow_mut().process_events(display.window());
+ let wakeup_request = processor.process_events(display.window());
// Handle config reloads
let config_updated = config_monitor.as_ref()
.and_then(|monitor| monitor.pending_config())
.map(|config| {
display.update_config(&config);
- processor.borrow_mut().update_config(&config);
+ processor.update_config(&config);
true
}).unwrap_or(false);
// Maybe draw the terminal
- let terminal = terminal.lock();
+ let mut terminal = terminal.lock();
if wakeup_request || config_updated {
+ // Handle pending resize events
+ //
+ // The second argument is a list of types that want to be notified
+ // of display size changes.
+ display.handle_resize(&mut terminal, &mut [&mut pty, &mut processor]);
+
+ // Draw the current state of the terminal
display.draw(terminal, &config);
}