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

Support startup notify on Wayland/X11

Activate a window to indicate that we want initial focus when the
system uses startup notifications.

Fixes #6931.
This commit is contained in:
Kirill Chibisov 2023-07-20 17:40:16 +04:00
parent bfcebbcd38
commit 8d174429ee
3 changed files with 18 additions and 0 deletions

View file

@ -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

View file

@ -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::<i32>::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)

View file

@ -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;