Skip to content

Commit

Permalink
fix: use enable and disable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
edfloreshz authored and wash2 committed Oct 30, 2024
1 parent ebdfa68 commit 2212e58
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
20 changes: 15 additions & 5 deletions runtime/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -460,9 +463,16 @@ pub fn disable_mouse_passthrough<Message>(id: Id) -> Task<Message> {
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<Message>(id: Id) -> Task<Message> {
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<Message>(enable: bool) -> Task<Message> {
task::effect(crate::Action::Window(Action::SetBlur(enable)))
pub fn disable_blur<Message>(id: Id) -> Task<Message> {
task::effect(crate::Action::Window(Action::DisableBlur(id)))
}
11 changes: 8 additions & 3 deletions winit/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2202,9 +2202,14 @@ fn run_action<P, C>(
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);
}
}
},
Expand Down

0 comments on commit 2212e58

Please sign in to comment.