From ebdfa688a326f2ff977b6891fc723db05bdfa9fe Mon Sep 17 00:00:00 2001 From: Eduardo Flores Date: Wed, 30 Oct 2024 16:42:25 +0100 Subject: [PATCH] improv: expose set_blur --- runtime/src/window.rs | 10 ++++++++++ winit/src/program.rs | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 48c200ec99..2086ffecba 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -159,6 +159,9 @@ pub enum Action { /// This enables mouse events for the window and stops mouse events /// from being passed to whatever is underneath. DisableMousePassthrough(Id), + + /// Set window blur. + SetBlur(bool), } /// Subscribes to the frames of the window of the running application. @@ -456,3 +459,10 @@ pub fn enable_mouse_passthrough(id: Id) -> Task { pub fn disable_mouse_passthrough(id: Id) -> Task { task::effect(crate::Action::Window(Action::DisableMousePassthrough(id))) } + +/// Sets the blur effect for the window. +/// +/// This is only supported on platforms that support window blur. +pub fn set_blur(enable: bool) -> Task { + task::effect(crate::Action::Window(Action::SetBlur(enable))) +} diff --git a/winit/src/program.rs b/winit/src/program.rs index 70b00f0c54..ffc8dd020f 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -2202,6 +2202,11 @@ fn run_action( let _ = window.raw.set_cursor_hittest(true); } } + window::Action::SetBlur(enable) => { + if let Some(window) = window_manager.get_mut(0) { + window.raw.set_blur(enable); + } + } }, Action::System(action) => match action { system::Action::QueryInformation(_channel) => {