diff --git a/CHANGELOG.md b/CHANGELOG.md index 85dd5f0b..776a7358 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `Back`/`Forward` mouse buttons support in bindings - Copy global IPC options (`-w -1`) for new windows - Bindings to create and navigate tabs on macOS +- Support startup notify protocol to raise initial window on Wayland/X11 ### Changed diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs index c7ad37c8..aef6e1b5 100644 --- a/alacritty/src/display/window.rs +++ b/alacritty/src/display/window.rs @@ -1,3 +1,8 @@ +#[cfg(not(any(target_os = "macos", windows)))] +use winit::platform::startup_notify::{ + self, EventLoopExtStartupNotify, WindowBuilderExtStartupNotify, +}; + #[cfg(all(not(feature = "x11"), not(any(target_os = "macos", windows))))] use winit::platform::wayland::WindowBuilderExtWayland; @@ -143,6 +148,17 @@ impl Window { .with_position(PhysicalPosition::::from((position.x, position.y))); } + #[cfg(not(any(target_os = "macos", windows)))] + if let Some(token) = event_loop.read_token_from_env() { + log::debug!("Activating window with token: {token:?}"); + window_builder = window_builder.with_activation_token(token); + + // Remove the token from the env. + unsafe { + startup_notify::reset_activation_token_env(); + } + } + let window = window_builder .with_title(&identity.title) .with_theme(config.window.decorations_theme_variant) diff --git a/extra/linux/Alacritty.desktop b/extra/linux/Alacritty.desktop index 0872a764..a99ef733 100644 --- a/extra/linux/Alacritty.desktop +++ b/extra/linux/Alacritty.desktop @@ -9,6 +9,7 @@ Categories=System;TerminalEmulator; Name=Alacritty GenericName=Terminal Comment=A fast, cross-platform, OpenGL terminal emulator +StartupNotify=true StartupWMClass=Alacritty Actions=New;