diff options
Diffstat (limited to 'alacritty')
-rw-r--r-- | alacritty/src/cli.rs | 4 | ||||
-rw-r--r-- | alacritty/src/config/ui_config.rs | 2 | ||||
-rw-r--r-- | alacritty/src/display/window.rs | 10 | ||||
-rw-r--r-- | alacritty/src/event.rs | 18 | ||||
-rw-r--r-- | alacritty/src/input/mod.rs | 5 | ||||
-rw-r--r-- | alacritty/src/window_context.rs | 2 |
6 files changed, 29 insertions, 12 deletions
diff --git a/alacritty/src/cli.rs b/alacritty/src/cli.rs index 5010ffc8..feac41bd 100644 --- a/alacritty/src/cli.rs +++ b/alacritty/src/cli.rs @@ -189,7 +189,7 @@ impl TerminalOptions { pty_config.shell = Some(command.into()); } - pty_config.hold |= self.hold; + pty_config.drain_on_exit |= self.hold; } } @@ -198,7 +198,7 @@ impl From<TerminalOptions> for PtyOptions { PtyOptions { working_directory: options.working_directory.take(), shell: options.command().map(Into::into), - hold: options.hold, + drain_on_exit: options.hold, env: HashMap::new(), } } diff --git a/alacritty/src/config/ui_config.rs b/alacritty/src/config/ui_config.rs index b44bda0d..53310090 100644 --- a/alacritty/src/config/ui_config.rs +++ b/alacritty/src/config/ui_config.rs @@ -130,7 +130,7 @@ impl UiConfig { let shell = self.terminal.shell.clone().or_else(|| self.shell.clone()).map(Into::into); let working_directory = self.working_directory.clone().or_else(|| self.general.working_directory.clone()); - PtyOptions { working_directory, shell, hold: false, env: HashMap::new() } + PtyOptions { working_directory, shell, drain_on_exit: false, env: HashMap::new() } } /// Generate key bindings for all keyboard hints. diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs index fe40fab5..f9fb9272 100644 --- a/alacritty/src/display/window.rs +++ b/alacritty/src/display/window.rs @@ -109,6 +109,9 @@ pub struct Window { /// Flag indicating whether redraw was requested. pub requested_redraw: bool, + /// Hold the window when terminal exits. + pub hold: bool, + window: WinitWindow, /// Current window title. @@ -127,7 +130,7 @@ impl Window { event_loop: &ActiveEventLoop, config: &UiConfig, identity: &Identity, - _options: &mut WindowOptions, + options: &mut WindowOptions, #[rustfmt::skip] #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] x11_visual: Option<X11VisualInfo>, @@ -139,7 +142,7 @@ impl Window { #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] x11_visual, #[cfg(target_os = "macos")] - &_options.window_tabbing_id.take(), + &options.window_tabbing_id.take(), ); if let Some(position) = config.window.position { @@ -148,7 +151,7 @@ impl Window { } #[cfg(not(any(target_os = "macos", windows)))] - if let Some(token) = _options + if let Some(token) = options .activation_token .take() .map(ActivationToken::from_raw) @@ -199,6 +202,7 @@ impl Window { let is_x11 = matches!(window.window_handle().unwrap().as_raw(), RawWindowHandle::Xlib(_)); Ok(Self { + hold: options.terminal_options.hold, requested_redraw: false, title: identity.title, current_mouse_cursor, diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 2ac6279d..888bec4f 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -4,6 +4,7 @@ use crate::ConfigMonitor; use glutin::config::GetGlConfig; use std::borrow::Cow; use std::cmp::min; +use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet, VecDeque}; use std::error::Error; use std::ffi::OsStr; @@ -380,9 +381,14 @@ impl ApplicationHandler<Event> for Processor { }, (EventType::Terminal(TerminalEvent::Exit), Some(window_id)) => { // Remove the closed terminal. - let window_context = match self.windows.remove(window_id) { - Some(window_context) => window_context, - None => return, + let window_context = match self.windows.entry(*window_id) { + // Don't exit when terminal exits if user asked to hold the window. + Entry::Occupied(window_context) + if !window_context.get().display.window.hold => + { + window_context.remove() + }, + _ => return, }; // Unschedule pending events. @@ -1793,7 +1799,11 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> { }, WinitEvent::WindowEvent { event, .. } => { match event { - WindowEvent::CloseRequested => self.ctx.terminal.exit(), + WindowEvent::CloseRequested => { + // User asked to close the window, so no need to hold it. + self.ctx.window().hold = false; + self.ctx.terminal.exit(); + }, WindowEvent::ScaleFactorChanged { scale_factor, .. } => { let old_scale_factor = mem::replace(&mut self.ctx.window().scale_factor, scale_factor); diff --git a/alacritty/src/input/mod.rs b/alacritty/src/input/mod.rs index 60a50529..3f85512f 100644 --- a/alacritty/src/input/mod.rs +++ b/alacritty/src/input/mod.rs @@ -324,7 +324,10 @@ impl<T: EventListener> Execute<T> for Action { #[cfg(not(target_os = "macos"))] Action::Hide => ctx.window().set_visible(false), Action::Minimize => ctx.window().set_minimized(true), - Action::Quit => ctx.terminal_mut().exit(), + Action::Quit => { + ctx.window().hold = false; + ctx.terminal_mut().exit(); + }, Action::IncreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP), Action::DecreaseFontSize => ctx.change_font_size(-FONT_SIZE_STEP), Action::ResetFontSize => ctx.reset_font_size(), diff --git a/alacritty/src/window_context.rs b/alacritty/src/window_context.rs index e3c39382..a0e66cc0 100644 --- a/alacritty/src/window_context.rs +++ b/alacritty/src/window_context.rs @@ -212,7 +212,7 @@ impl WindowContext { Arc::clone(&terminal), event_proxy.clone(), pty, - pty_config.hold, + pty_config.drain_on_exit, config.debug.ref_test, )?; |