Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose blur to the user #184

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions runtime/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ pub enum Action {
/// This enables mouse events for the window and stops mouse events
/// from being passed to whatever is underneath.
DisableMousePassthrough(Id),

/// 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 @@ -456,3 +462,17 @@ pub fn enable_mouse_passthrough<Message>(id: Id) -> Task<Message> {
pub fn disable_mouse_passthrough<Message>(id: Id) -> Task<Message> {
task::effect(crate::Action::Window(Action::DisableMousePassthrough(id)))
}

/// 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)))
}

/// Disable the blur effect for a window.
///
/// This is only supported on platforms that support window blur.
pub fn disable_blur<Message>(id: Id) -> Task<Message> {
task::effect(crate::Action::Window(Action::DisableBlur(id)))
}
10 changes: 10 additions & 0 deletions winit/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use crate::futures::{Executor, Runtime};
use crate::graphics;
use crate::graphics::{compositor, Compositor};
use crate::platform_specific;

Check warning on line 29 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused import: `crate::platform_specific`

Check warning on line 29 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused import: `crate::platform_specific`
use crate::runtime::user_interface::{self, UserInterface};
use crate::runtime::Debug;
use crate::runtime::{self, Action, Task};
Expand Down Expand Up @@ -378,8 +378,8 @@

#[cfg(target_arch = "wasm32")]
{
use winit::platform::web::WindowExtWebSys;

Check failure on line 381 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowExtWebSys`

Check failure on line 381 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowExtWebSys`
self.canvas = window.canvas();

Check failure on line 382 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `canvas` found for struct `std::sync::Arc<dyn winit::window::Window>` in the current scope

Check failure on line 382 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `canvas` found for struct `std::sync::Arc<dyn winit::window::Window>` in the current scope
}

let finish_boot = async move {
Expand Down Expand Up @@ -495,14 +495,14 @@

#[cfg(target_arch = "wasm32")]
let window_attributes = {
use winit::platform::web::WindowAttributesExtWebSys;

Check failure on line 498 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowAttributesExtWebSys`

Check failure on line 498 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowAttributesExtWebSys`
window_attributes
.with_canvas(self.canvas.take())

Check failure on line 500 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `with_canvas` found for struct `WindowAttributes` in the current scope

Check failure on line 500 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `with_canvas` found for struct `WindowAttributes` in the current scope
};

log::info!("Window attributes for id `{id:#?}`: {window_attributes:#?}");

let window = Arc::from(

Check failure on line 505 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

type annotations needed for `std::sync::Arc<_, _>`

Check failure on line 505 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

type annotations needed for `std::sync::Arc<_, _>`
event_loop
.create_window(window_attributes)
.expect("Create window"),
Expand All @@ -510,7 +510,7 @@

#[cfg(target_arch = "wasm32")]
{
use winit::platform::web::WindowExtWebSys;

Check failure on line 513 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::WindowExtWebSys`

Check failure on line 513 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::WindowExtWebSys`

let canvas = window
.canvas()
Expand Down Expand Up @@ -630,8 +630,8 @@

#[cfg(target_arch = "wasm32")]
{
use winit::platform::web::EventLoopExtWebSys;

Check failure on line 633 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unresolved import `winit::platform::web::EventLoopExtWebSys`

Check failure on line 633 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unresolved import `winit::platform::web::EventLoopExtWebSys`
let _ = event_loop.spawn_app(runner);

Check failure on line 634 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

no method named `spawn_app` found for struct `EventLoop` in the current scope

Check failure on line 634 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

no method named `spawn_app` found for struct `EventLoop` in the current scope

Ok(())
}
Expand Down Expand Up @@ -693,7 +693,7 @@
boot: oneshot::Receiver<Boot<C>>,
mut event_receiver: mpsc::UnboundedReceiver<Event<P::Message>>,
mut control_sender: mpsc::UnboundedSender<Control>,
display_handle: OwnedDisplayHandle,

Check warning on line 696 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused variable: `display_handle`

Check warning on line 696 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused variable: `display_handle`
is_daemon: bool,
) where
P: Program + 'static,
Expand All @@ -705,7 +705,7 @@

let Boot {
mut compositor,
is_wayland,

Check warning on line 708 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unused variable: `is_wayland`

Check warning on line 708 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unused variable: `is_wayland`
} = boot.await.expect("Receive boot");

let mut platform_specific_handler =
Expand Down Expand Up @@ -1231,7 +1231,7 @@
{
let logical_size = window.state.logical_size();
debug.layout_started();
let mut ui = user_interfaces

Check warning on line 1234 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

variable does not need to be mutable

Check warning on line 1234 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

variable does not need to be mutable
.remove(&id)
.expect("Remove user interface")
.relayout(logical_size, &mut window.renderer);
Expand Down Expand Up @@ -1501,7 +1501,7 @@
}
}
}
_ => {}

Check warning on line 1504 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / web

unreachable pattern

Check warning on line 1504 in winit/src/program.rs

View workflow job for this annotation

GitHub Actions / wasm

unreachable pattern
}
}
Event::AboutToWait => {
Expand Down Expand Up @@ -2202,6 +2202,16 @@
let _ = window.raw.set_cursor_hittest(true);
}
}
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);
}
}
},
Action::System(action) => match action {
system::Action::QueryInformation(_channel) => {
Expand Down
Loading