From 1df7dc5171abfe1eab3e95be964f61c5876198f1 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 23 Oct 2021 07:16:47 +0000 Subject: Add multi-window support Previously Alacritty would always initialize only a single terminal emulator window feeding into the winit event loop, however some platforms like macOS expect all windows to be spawned by the same process and this "daemon-mode" can also come with the advantage of increased memory efficiency. The event loop has been restructured to handle all window-specific events only by the event processing context with the associated window id. This makes it possible to add new terminal windows at any time using the WindowContext::new function call. Some preliminary tests have shown that for empty terminals, this reduces the cost of additional terminal emulators from ~100M to ~6M. However at this point the robustness of the daemon against issues with individual terminals has not been refined, making the reliability of this system questionable. New windows can be created either by using the new `CreateNewWindow` action, or with the `alacritty msg create-window` subcommand. The subcommand sends a message to an IPC socket which Alacritty listens on, its location can be found in the `ALACRITTY_SOCKET` environment variable. Fixes #607. --- alacritty/src/config/monitor.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'alacritty/src/config/monitor.rs') diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs index e3dd0556..9d37172e 100644 --- a/alacritty/src/config/monitor.rs +++ b/alacritty/src/config/monitor.rs @@ -2,19 +2,20 @@ use std::path::PathBuf; use std::sync::mpsc; use std::time::Duration; +use glutin::event_loop::EventLoopProxy; use log::{debug, error}; use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use alacritty_terminal::thread; -use crate::event::{Event, EventProxy}; +use crate::event::{Event, EventType}; #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] const DEBOUNCE_DELAY: Duration = Duration::from_millis(10); #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))] const DEBOUNCE_DELAY: Duration = Duration::from_millis(1000); -pub fn watch(mut paths: Vec, event_proxy: EventProxy) { +pub fn watch(mut paths: Vec, event_proxy: EventLoopProxy) { // Don't monitor config if there is no path to watch. if paths.is_empty() { return; @@ -77,9 +78,10 @@ pub fn watch(mut paths: Vec, event_proxy: EventProxy) { if paths.contains(&path) => { // Always reload the primary configuration file. - event_proxy.send_event(Event::ConfigReload(paths[0].clone())); + let event = Event::new(EventType::ConfigReload(paths[0].clone()), None); + let _ = event_proxy.send_event(event); } - _ => {}, + _ => (), } } }); -- cgit