Skip to content

Commit

Permalink
Fix dynamic title override for multiple windows
Browse files Browse the repository at this point in the history
This fixes an issue where Windows spawned after the initial one through
IPC or bindings would not update their title due to the initial window
having its title set through the CLI.

Title changes are still inhibited for additional windows when they are
spawned through `alacritty msg create-window` with the `--title` CLI
option added.

Closes #6836.
  • Loading branch information
chrisduerr committed Apr 23, 2024
1 parent 9005461 commit ce800bf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Notable changes to the `alacritty_terminal` crate are documented in its
- Crash when trying to create a new tab without decorations enabled
- New window being treated as focused when it's not on Wayland
- IME preview blending into text below it
- Dynamic title disabled for new windows when initial one has title as CLI option

## 0.13.2

Expand Down
14 changes: 0 additions & 14 deletions alacritty/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ impl Options {
config.ipc_socket |= self.socket.is_some();
}

config.window.dynamic_title &= self.window_options.window_identity.title.is_none();
config.window.embed = self.embed.as_ref().and_then(|embed| parse_hex_or_decimal(embed));
config.debug.print_events |= self.print_events;
config.debug.log_level = max(config.debug.log_level, self.log_level());
Expand Down Expand Up @@ -425,19 +424,6 @@ mod tests {
assert_eq!(old_dynamic_title, config.window.dynamic_title);
}

#[test]
fn dynamic_title_overridden_by_options() {
let mut config = UiConfig::default();

let title = Some(String::from("foo"));
let window_identity = WindowIdentity { title, ..WindowIdentity::default() };
let new_window_options = WindowOptions { window_identity, ..WindowOptions::default() };
let mut options = Options { window_options: new_window_options, ..Options::default() };
options.override_config(&mut config);

assert!(!config.window.dynamic_title);
}

#[test]
fn dynamic_title_not_overridden_by_config() {
let mut config = UiConfig::default();
Expand Down
9 changes: 6 additions & 3 deletions alacritty/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ pub struct ActionContext<'a, N, T> {
pub message_buffer: &'a mut MessageBuffer,
pub config: &'a UiConfig,
pub cursor_blink_timed_out: &'a mut bool,
#[cfg(target_os = "macos")]
pub event_loop: &'a EventLoopWindowTarget<Event>,
pub event_proxy: &'a EventLoopProxy<Event>,
pub scheduler: &'a mut Scheduler,
Expand Down Expand Up @@ -1213,7 +1214,6 @@ pub struct Mouse {
pub click_state: ClickState,
pub accumulated_scroll: AccumulatedScroll,
pub cell_side: Side,
pub lines_scrolled: f32,
pub block_hint_launcher: bool,
pub hint_highlight_dirty: bool,
pub inside_text_area: bool,
Expand All @@ -1234,7 +1234,6 @@ impl Default for Mouse {
hint_highlight_dirty: Default::default(),
block_hint_launcher: Default::default(),
inside_text_area: Default::default(),
lines_scrolled: Default::default(),
accumulated_scroll: Default::default(),
x: Default::default(),
y: Default::default(),
Expand Down Expand Up @@ -1313,7 +1312,7 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
},
TerminalEvent::ResetTitle => {
let window_config = &self.ctx.config.window;
if window_config.dynamic_title {
if !self.ctx.preserve_title && window_config.dynamic_title {
self.ctx.display.window.set_title(window_config.identity.title.clone());
}
},
Expand Down Expand Up @@ -1694,6 +1693,7 @@ impl Processor {
};

window_context.handle_event(
#[cfg(target_os = "macos")]
event_loop,
&proxy,
&mut clipboard,
Expand All @@ -1708,6 +1708,7 @@ impl Processor {
// Dispatch event to all windows.
for window_context in self.windows.values_mut() {
window_context.handle_event(
#[cfg(target_os = "macos")]
event_loop,
&proxy,
&mut clipboard,
Expand Down Expand Up @@ -1794,6 +1795,7 @@ impl Processor {
WinitEvent::UserEvent(event @ Event { window_id: None, .. }) => {
for window_context in self.windows.values_mut() {
window_context.handle_event(
#[cfg(target_os = "macos")]
event_loop,
&proxy,
&mut clipboard,
Expand All @@ -1807,6 +1809,7 @@ impl Processor {
| WinitEvent::UserEvent(Event { window_id: Some(window_id), .. }) => {
if let Some(window_context) = self.windows.get_mut(&window_id) {
window_context.handle_event(
#[cfg(target_os = "macos")]
event_loop,
&proxy,
&mut clipboard,
Expand Down
3 changes: 2 additions & 1 deletion alacritty/src/window_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ impl WindowContext {
/// Process events for this terminal window.
pub fn handle_event(
&mut self,
event_loop: &EventLoopWindowTarget<Event>,
#[cfg(target_os = "macos")] event_loop: &EventLoopWindowTarget<Event>,
event_proxy: &EventLoopProxy<Event>,
clipboard: &mut Clipboard,
scheduler: &mut Scheduler,
Expand Down Expand Up @@ -445,6 +445,7 @@ impl WindowContext {
preserve_title: self.preserve_title,
config: &self.config,
event_proxy,
#[cfg(target_os = "macos")]
event_loop,
clipboard,
scheduler,
Expand Down

0 comments on commit ce800bf

Please sign in to comment.