Add `window.blur` config option

Fixes #972.
This commit is contained in:
Kirill Chibisov 2023-10-29 16:18:33 +04:00 committed by GitHub
parent 0db2fc7865
commit a0663c5225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 10 deletions

View File

@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Support startup notify protocol to raise initial window on Wayland/X11
- Debug option `prefer_egl` to prioritize EGL over other display APIs
- Inline vi-mode search using `f`/`F`/`t`/`T`
- `window.blur` config option to request blur for transparent windows
### Changed

4
Cargo.lock generated
View File

@ -2386,9 +2386,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "winit"
version = "0.29.2"
version = "0.29.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b829f75d02fe1e225b97c91a04c326900147a50234d1141a1cbe215ce8798c11"
checksum = "161598019a9da35ab6c34dc46cd13546cba9dbf9816475d4dd9a639455016563"
dependencies = [
"ahash",
"android-activity",

View File

@ -41,7 +41,7 @@ serde_json = "1"
serde_yaml = "0.9.25"
toml = "0.8.2"
unicode-width = "0.1"
winit = { version = "0.29.2", default-features = false, features = ["rwh_05", "serde"] }
winit = { version = "0.29.3", default-features = false, features = ["rwh_05", "serde"] }
[build-dependencies]
gl_generator = "0.14.0"

View File

@ -48,6 +48,9 @@ pub struct WindowConfig {
/// Background opacity from 0.0 to 1.0.
pub opacity: Percentage,
/// Request blur behind the window.
pub blur: bool,
/// Controls which `Option` key should be treated as `Alt`.
#[cfg(target_os = "macos")]
option_as_alt: OptionAsAlt,
@ -66,17 +69,18 @@ impl Default for WindowConfig {
fn default() -> Self {
Self {
dynamic_title: true,
blur: Default::default(),
embed: Default::default(),
padding: Default::default(),
opacity: Default::default(),
position: Default::default(),
identity: Default::default(),
dimensions: Default::default(),
decorations: Default::default(),
startup_mode: Default::default(),
embed: Default::default(),
decorations_theme_variant: Default::default(),
dynamic_padding: Default::default(),
identity: Identity::default(),
opacity: Default::default(),
padding: Default::default(),
dimensions: Default::default(),
resize_increments: Default::default(),
decorations_theme_variant: Default::default(),
#[cfg(target_os = "macos")]
option_as_alt: Default::default(),
}

View File

@ -167,6 +167,7 @@ impl Window {
.with_theme(config.window.decorations_theme_variant)
.with_visible(false)
.with_transparent(true)
.with_blur(config.window.blur)
.with_maximized(config.window.maximized())
.with_fullscreen(config.window.fullscreen())
.build(event_loop)?;
@ -343,6 +344,10 @@ impl Window {
self.window.set_transparent(transparent);
}
pub fn set_blur(&self, blur: bool) {
self.window.set_blur(blur);
}
pub fn set_maximized(&self, maximized: bool) {
self.window.set_maximized(maximized);
}

View File

@ -345,8 +345,9 @@ impl WindowContext {
#[cfg(target_os = "macos")]
self.display.window.set_option_as_alt(self.config.window.option_as_alt());
// Change opacity state.
// Change opacity and blur state.
self.display.window.set_transparent(!opaque);
self.display.window.set_blur(self.config.window.blur);
// Update hint keys.
self.display.hint_state.update_alphabet(self.config.hints.alphabet());

View File

@ -133,6 +133,12 @@ This section documents the *[window]* table of the configuration file.
Default: _1.0_
*blur* <boolean> _(works on macOS/KDE Wayland)_
Request compositor to blur content behind transparent windows.
Default: _false_
*startup_mode* "Windowed" | "Maximized" | "Fullscreen" | "SimpleFullscreen"
Startup mode (changes require restart)