From 39ea7271e32ad88280191d8040d6f8feafe4307a Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 2 Nov 2024 12:23:33 -0700 Subject: [PATCH] Focus new windows on macOS --- CHANGELOG.md | 4 ++++ alacritty/src/display/mod.rs | 4 ++++ alacritty/src/display/window.rs | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 095d5fd7..1c28ddd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ Notable changes to the `alacritty_terminal` crate are documented in its ## 0.15.0-dev +### Changed + +- Always focus new windows on macOS + ### Fixed - Mouse/Vi cursor hint highlighting broken on the terminal cursor line diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs index d358a7c5..4211da5f 100644 --- a/alacritty/src/display/mod.rs +++ b/alacritty/src/display/mod.rs @@ -484,6 +484,10 @@ impl Display { window.set_visible(true); + // Always focus new windows, even if no Alacritty window is currently focused. + #[cfg(target_os = "macos")] + window.focus_window(); + #[allow(clippy::single_match)] #[cfg(not(windows))] if !_tabbed { diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs index 1427dc75..5f0790b6 100644 --- a/alacritty/src/display/window.rs +++ b/alacritty/src/display/window.rs @@ -224,6 +224,12 @@ impl Window { self.window.set_visible(visibility); } + #[cfg(target_os = "macos")] + #[inline] + pub fn focus_window(&self) { + self.window.focus_window(); + } + /// Set the window title. #[inline] pub fn set_title(&mut self, title: String) {