From 1ed7529b7ec53fa9000df3fc96faf67253456448 Mon Sep 17 00:00:00 2001 From: Eduardo Flores Date: Wed, 30 Oct 2024 16:42:25 +0100 Subject: [PATCH 1/3] 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) => { From 8996012fdea8fbe63cc31962707b9bdd67b48967 Mon Sep 17 00:00:00 2001 From: Eduardo Flores Date: Wed, 30 Oct 2024 17:19:19 +0100 Subject: [PATCH 2/3] fix: use enable and disable methods --- runtime/src/window.rs | 20 +++++++++++++++----- winit/src/program.rs | 11 ++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 2086ffecba..ff9660b744 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -160,8 +160,11 @@ pub enum Action { /// from being passed to whatever is underneath. DisableMousePassthrough(Id), - /// Set window blur. - SetBlur(bool), + /// Enable window blur. + EnableBlur(Id), + + /// Disable window blur. + DisableBlur(Id), } /// Subscribes to the frames of the window of the running application. @@ -460,9 +463,16 @@ pub fn disable_mouse_passthrough(id: Id) -> Task { task::effect(crate::Action::Window(Action::DisableMousePassthrough(id))) } -/// Sets the blur effect for the window. +/// Enable the blur effect for a window. +/// +/// This is only supported on platforms that support window blur. +pub fn enable_blur(id: Id) -> Task { + task::effect(crate::Action::Window(Action::EnableBlur(id))) +} + +/// Enable the blur effect for a 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))) +pub fn disable_blur(id: Id) -> Task { + task::effect(crate::Action::Window(Action::DisableBlur(id))) } diff --git a/winit/src/program.rs b/winit/src/program.rs index ffc8dd020f..a12ec20bc2 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -2202,9 +2202,14 @@ 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); + window::Action::EnableBlur(id) => { + if let Some(window) = window_manager.get_mut(id) { + window.raw.set_blur(true); + } + } + window::Action::DisableBlur(id) => { + if let Some(window) = window_manager.get_mut(id) { + window.raw.set_blur(false); } } }, From ca4c6f8baef329b39834035dc4d6a032620f44d8 Mon Sep 17 00:00:00 2001 From: Eduardo Flores Date: Wed, 30 Oct 2024 17:49:24 +0100 Subject: [PATCH 3/3] fix: documentation --- runtime/src/window.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/window.rs b/runtime/src/window.rs index ff9660b744..59c8d59296 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -470,7 +470,7 @@ pub fn enable_blur(id: Id) -> Task { task::effect(crate::Action::Window(Action::EnableBlur(id))) } -/// Enable the blur effect for a window. +/// Disable the blur effect for a window. /// /// This is only supported on platforms that support window blur. pub fn disable_blur(id: Id) -> Task {