Skip to content

Add window.level to set window level (Normal, AlwaysOnTop). #8269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Notable changes to the `alacritty_terminal` crate are documented in its

## 0.15.0-dev

### Added

- Config option `window.level = "AlwaysOnTop"` to force Alacritty to always be the toplevel window

### Changed

- Always focus new windows on macOS
Expand Down
2 changes: 1 addition & 1 deletion alacritty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ tempfile = "3.12.0"
toml = "0.8.2"
toml_edit = "0.22.21"
unicode-width = "0.1"
winit = { version = "0.30.4", default-features = false, features = ["rwh_06", "serde"] }
winit = { version = "0.30.5", default-features = false, features = ["rwh_06", "serde"] }

[build-dependencies]
gl_generator = "0.14.0"
Expand Down
22 changes: 21 additions & 1 deletion alacritty/src/config/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize};

#[cfg(target_os = "macos")]
use winit::platform::macos::OptionAsAlt as WinitOptionAsAlt;
use winit::window::{Fullscreen, Theme as WinitTheme};
use winit::window::{Fullscreen, Theme as WinitTheme, WindowLevel as WinitWindowLevel};

use alacritty_config_derive::{ConfigDeserialize, SerdeReplace};

Expand Down Expand Up @@ -61,6 +61,9 @@ pub struct WindowConfig {

/// System decorations theme variant.
decorations_theme_variant: Option<Theme>,

/// Window level.
pub level: WindowLevel,
}

impl Default for WindowConfig {
Expand All @@ -80,6 +83,7 @@ impl Default for WindowConfig {
resize_increments: Default::default(),
decorations_theme_variant: Default::default(),
option_as_alt: Default::default(),
level: Default::default(),
}
}
}
Expand Down Expand Up @@ -306,3 +310,19 @@ impl From<Theme> for WinitTheme {
}
}
}

#[derive(ConfigDeserialize, Default, Debug, Clone, Copy, PartialEq, Eq)]
pub enum WindowLevel {
#[default]
Normal,
AlwaysOnTop,
}

impl From<WindowLevel> for WinitWindowLevel {
fn from(level: WindowLevel) -> Self {
match level {
WindowLevel::Normal => WinitWindowLevel::Normal,
WindowLevel::AlwaysOnTop => WinitWindowLevel::AlwaysOnTop,
}
}
}
3 changes: 2 additions & 1 deletion alacritty/src/display/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ impl Window {
.with_transparent(true)
.with_blur(config.window.blur)
.with_maximized(config.window.maximized())
.with_fullscreen(config.window.fullscreen());
.with_fullscreen(config.window.fullscreen())
.with_window_level(config.window.level.into());

let window = event_loop.create_window(window_attributes)?;

Expand Down
11 changes: 11 additions & 0 deletions extra/man/alacritty.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ This section documents the *[window]* table of the configuration file.

Default: _"None"_

*level* = _"Normal"_ | _"AlwaysOnTop"_

Sets window level.

*Normal*
Window adheres to system's default z-order.
*AlwaysOnTop*
Window is a toplevel window.

Default: _"Normal"_

Example:
*[window]*++
padding = { x = _3_, y = _3_ }++
Expand Down