Add Window::set_blur

Allow clients to request blur behind their window, implemented on
Wayland for now.
This commit is contained in:
Dmitry Sharshakov 2023-10-08 22:53:15 +03:00 committed by GitHub
parent f5dd1c008c
commit 0363be4776
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 167 additions and 2 deletions

View file

@ -151,6 +151,7 @@ pub struct WindowAttributes {
pub maximized: bool,
pub visible: bool,
pub transparent: bool,
pub blur: bool,
pub decorations: bool,
pub window_icon: Option<Icon>,
pub preferred_theme: Option<Theme>,
@ -176,6 +177,7 @@ impl Default for WindowAttributes {
fullscreen: None,
visible: true,
transparent: false,
blur: false,
decorations: true,
window_level: Default::default(),
window_icon: None,
@ -343,6 +345,17 @@ impl WindowBuilder {
self
}
/// Sets whether the background of the window should be blurred by the system.
///
/// The default is `false`.
///
/// See [`Window::set_blur`] for details.
#[inline]
pub fn with_blur(mut self, blur: bool) -> Self {
self.window.blur = blur;
self
}
/// Get whether the window will support transparency.
#[inline]
pub fn transparent(&self) -> bool {
@ -884,6 +897,19 @@ impl Window {
.maybe_queue_on_main(move |w| w.set_transparent(transparent))
}
/// Change the window blur state.
///
/// If `true`, this will make the transparent window background blurry.
///
/// ## Platform-specific
///
/// - **Android / iOS / macOS / X11 / Web / Windows:** Unsupported.
/// - **Wayland:** Only works with org_kde_kwin_blur_manager protocol.
#[inline]
pub fn set_blur(&self, blur: bool) {
self.window.maybe_queue_on_main(move |w| w.set_blur(blur))
}
/// Modifies the window's visibility.
///
/// If `false`, this will hide the window. If `true`, this will show the window.