diff options
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r-- | alacritty/src/event.rs | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index b4258a03..bd4b60b2 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -9,6 +9,7 @@ use std::fmt::Debug; #[cfg(not(windows))] use std::os::unix::io::RawFd; use std::path::PathBuf; +use std::rc::Rc; use std::time::{Duration, Instant}; use std::{env, f32, mem}; @@ -38,6 +39,8 @@ use alacritty_terminal::selection::{Selection, SelectionType}; use alacritty_terminal::term::search::{Match, RegexSearch}; use alacritty_terminal::term::{self, ClipboardType, Term, TermMode}; +#[cfg(unix)] +use crate::cli::IpcConfig; use crate::cli::{Options as CliOptions, WindowOptions}; use crate::clipboard::Clipboard; use crate::config::ui_config::{HintAction, HintInternalAction}; @@ -93,6 +96,8 @@ pub enum EventType { Message(Message), Scroll(Scroll), CreateWindow(WindowOptions), + #[cfg(unix)] + IpcConfig(IpcConfig), BlinkCursor, BlinkCursorTimeout, SearchNext, @@ -184,7 +189,7 @@ pub struct ActionContext<'a, N, T> { pub modifiers: &'a mut ModifiersState, pub display: &'a mut Display, pub message_buffer: &'a mut MessageBuffer, - pub config: &'a mut UiConfig, + pub config: &'a UiConfig, pub cursor_blink_timed_out: &'a mut bool, pub event_loop: &'a EventLoopWindowTarget<Event>, pub event_proxy: &'a EventLoopProxy<Event>, @@ -1162,6 +1167,8 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> { TerminalEvent::Exit => (), TerminalEvent::CursorBlinkingChange => self.ctx.update_cursor_blinking(), }, + #[cfg(unix)] + EventType::IpcConfig(_) => (), EventType::ConfigReload(_) | EventType::CreateWindow(_) => (), }, GlutinEvent::RedrawRequested(_) => *self.ctx.dirty = true, @@ -1292,7 +1299,7 @@ pub struct Processor { wayland_event_queue: Option<EventQueue>, windows: HashMap<WindowId, WindowContext>, cli_options: CliOptions, - config: UiConfig, + config: Rc<UiConfig>, } impl Processor { @@ -1313,8 +1320,8 @@ impl Processor { Processor { windows: HashMap::new(), + config: Rc::new(config), cli_options, - config, #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))] wayland_event_queue, } @@ -1328,7 +1335,7 @@ impl Processor { options: WindowOptions, ) -> Result<(), Box<dyn Error>> { let window_context = WindowContext::new( - &self.config, + self.config.clone(), &options, event_loop, proxy, @@ -1436,7 +1443,6 @@ impl Processor { window_context.handle_event( event_loop, &proxy, - &mut self.config, &mut clipboard, &mut scheduler, GlutinEvent::RedrawEventsCleared, @@ -1457,13 +1463,27 @@ impl Processor { // Load config and update each terminal. if let Ok(config) = config::reload(&path, &self.cli_options) { - let old_config = mem::replace(&mut self.config, config); + self.config = Rc::new(config); for window_context in self.windows.values_mut() { - window_context.update_config(&old_config, &self.config); + window_context.update_config(self.config.clone()); } } }, + // Process IPC config update. + #[cfg(unix)] + GlutinEvent::UserEvent(Event { + payload: EventType::IpcConfig(ipc_config), + window_id, + }) => { + for (_, window_context) in self + .windows + .iter_mut() + .filter(|(id, _)| window_id.is_none() || window_id == Some(**id)) + { + window_context.update_ipc_config(self.config.clone(), ipc_config.clone()); + } + }, // Create a new terminal window. GlutinEvent::UserEvent(Event { payload: EventType::CreateWindow(options), .. @@ -1485,7 +1505,6 @@ impl Processor { window_context.handle_event( event_loop, &proxy, - &mut self.config, &mut clipboard, &mut scheduler, event.clone().into(), @@ -1500,7 +1519,6 @@ impl Processor { window_context.handle_event( event_loop, &proxy, - &mut self.config, &mut clipboard, &mut scheduler, event, |