1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00

Copy global IPC options for new windows

This patch stores all options set for the Window ID `-1` and
automatically applies them to new windows after their creation.

This in theory makes it possible to have a fully dynamic "default
config" without having to reapply it for every new window.

Closes #7128.
This commit is contained in:
Christian Duerr 2023-08-07 23:14:53 +02:00 committed by GitHub
parent 35e1bb128b
commit bbe3174381
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View file

@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Support for dynamically loading conpty.dll on Windows
- Support for keybindings with dead keys
- `Back`/`Forward` mouse buttons support in bindings
- Copy global IPC options (`-w -1`) for new windows
### Changed

View file

@ -1403,6 +1403,8 @@ pub struct Processor {
#[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
wayland_event_queue: Option<EventQueue>,
windows: HashMap<WindowId, WindowContext, RandomState>,
#[cfg(unix)]
global_ipc_options: Vec<String>,
cli_options: CliOptions,
config: Rc<UiConfig>,
}
@ -1424,11 +1426,13 @@ impl Processor {
});
Processor {
windows: Default::default(),
config: Rc::new(config),
cli_options,
#[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
wayland_event_queue,
#[cfg(unix)]
global_ipc_options: Default::default(),
windows: Default::default(),
}
}
@ -1464,7 +1468,9 @@ impl Processor {
options: WindowOptions,
) -> Result<(), Box<dyn Error>> {
let window = self.windows.iter().next().as_ref().unwrap().1;
let window_context = window.additional(
#[allow(unused_mut)]
let mut window_context = window.additional(
event_loop,
proxy,
self.config.clone(),
@ -1473,6 +1479,14 @@ impl Processor {
self.wayland_event_queue.as_ref(),
)?;
// Apply global IPC options.
#[cfg(unix)]
{
let options = self.global_ipc_options.clone();
let ipc_config = IpcConfig { options, window_id: None, reset: false };
window_context.update_ipc_config(self.config.clone(), ipc_config);
}
self.windows.insert(window_context.id(), window_context);
Ok(())
}
@ -1609,6 +1623,15 @@ impl Processor {
payload: EventType::IpcConfig(ipc_config),
window_id,
}) => {
// Persist global options for future windows.
if window_id.is_none() {
if ipc_config.reset {
self.global_ipc_options.clear();
} else {
self.global_ipc_options.extend_from_slice(&ipc_config.options);
}
}
for (_, window_context) in self
.windows
.iter_mut()