aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/event.rs
diff options
context:
space:
mode:
authorAndrew Borg (Kashin) <1192958+aborg-dev@users.noreply.github.com>2025-01-16 15:04:21 +0000
committerGitHub <noreply@github.com>2025-01-16 15:04:21 +0000
commit5e78d20c709cb1ab8d44ca7a8702cc26d779227c (patch)
treef5174dfb36771fbfb149b338f000ab27c119baab /alacritty/src/event.rs
parentc9c41e637ac49f3cd67cf0362c596ae9d947f896 (diff)
downloadr-alacritty-5e78d20c709cb1ab8d44ca7a8702cc26d779227c.tar.gz
r-alacritty-5e78d20c709cb1ab8d44ca7a8702cc26d779227c.tar.bz2
r-alacritty-5e78d20c709cb1ab8d44ca7a8702cc26d779227c.zip
Add option to drain PTY on shutdown
This patch removes the `hold` option on `alacritty_terminal` in favor of a `drain_on_exit` option, which will drain the PTY before shutdown. The hold logic is instead handled in `alacritty`.
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r--alacritty/src/event.rs18
1 files changed, 14 insertions, 4 deletions
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);