T20: on Wayland the window asks for ext_background_effect_v1 on its surface, through a guest connection on gpui's display; one region wider than any window, which the compositor clips, comes and goes with Blurred; the log names the way blur goes; a wayland-server compositor tests it, and scripts/linux.sh runs the tests on Linux in a container
This commit is contained in:
8 files changed
+529
-13
No files matched your search
+34
-5
@@ -2,6 +2,9 @@ use gpui::{Window, WindowBackgroundAppearance};
|
||||
|
||||
use crate::settings::Settings;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod wayland;
|
||||
|
||||
/// What the window shows of the desktop: blurred or clear while the background lets it through.
|
||||
pub fn appearance(settings: &Settings) -> WindowBackgroundAppearance {
|
||||
if settings.background_opacity >= 1.0 {
|
||||
@@ -13,13 +16,39 @@ pub fn appearance(settings: &Settings) -> WindowBackgroundAppearance {
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets `window` to what the settings ask when it differs from `shown`; logs the way taken.
|
||||
pub fn follow(window: &Window, shown: &mut WindowBackgroundAppearance, settings: &Settings) {
|
||||
let wanted = appearance(settings);
|
||||
if wanted != *shown {
|
||||
*shown = wanted;
|
||||
/// What the main window shows of the desktop, as last set, and on Wayland the blur behind its surface.
|
||||
pub struct Blur {
|
||||
shown: WindowBackgroundAppearance,
|
||||
#[cfg(target_os = "linux")]
|
||||
wayland: Option<wayland::Effect>,
|
||||
}
|
||||
|
||||
impl Blur {
|
||||
/// The window as `WindowOptions` opened it from these settings.
|
||||
pub fn new(window: &Window, settings: &Settings) -> Self {
|
||||
let shown = appearance(settings);
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let _ = window;
|
||||
Self {
|
||||
shown,
|
||||
#[cfg(target_os = "linux")]
|
||||
wayland: wayland::Effect::on(window, shown == WindowBackgroundAppearance::Blurred),
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the window to what the settings ask when it differs from what it shows; logs the way taken.
|
||||
pub fn follow(&mut self, window: &Window, settings: &Settings) {
|
||||
let wanted = appearance(settings);
|
||||
if wanted == self.shown {
|
||||
return;
|
||||
}
|
||||
self.shown = wanted;
|
||||
window.set_background_appearance(wanted);
|
||||
log::info!("blur: the window is {wanted:?} on {}", std::env::consts::OS);
|
||||
#[cfg(target_os = "linux")]
|
||||
if let Some(effect) = &self.wayland {
|
||||
effect.blur(wanted == WindowBackgroundAppearance::Blurred);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user