From 8d174429ee1e63e865a9203d7dfc4ce2cd25576d Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 20 Jul 2023 17:40:16 +0400 Subject: Support startup notify on Wayland/X11 Activate a window to indicate that we want initial focus when the system uses startup notifications. Fixes #6931. --- alacritty/src/display/window.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'alacritty/src') 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) -- cgit