wip
This commit is contained in:
parent
a489a6b790
commit
e2918e0de9
19 changed files with 9291 additions and 60 deletions
|
|
@ -12,7 +12,7 @@ use crate::task::{self, Task};
|
|||
|
||||
pub use raw_window_handle;
|
||||
|
||||
use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
|
||||
use raw_window_handle::{HasDisplayHandle, HasWindowHandle, WindowHandle};
|
||||
|
||||
/// An operation to be performed on some window.
|
||||
pub enum Action {
|
||||
|
|
@ -90,6 +90,9 @@ pub enum Action {
|
|||
/// - **Web:** Unsupported.
|
||||
ToggleDecorations(Id),
|
||||
|
||||
/// Runs the closure with the native window handle of the window with the given [`Id`].
|
||||
RunWithHandle(Id, Box<dyn FnOnce(WindowHandle<'_>) + Send>),
|
||||
|
||||
/// Request user attention to the window, this has no effect if the application
|
||||
/// is already focused. How requesting for user attention manifests is platform dependent,
|
||||
/// see [`UserAttention`] for details.
|
||||
|
|
@ -505,6 +508,26 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
/// Runs the given callback with the native window handle for the window with the given id.
|
||||
///
|
||||
/// Note that if the window closes before this call is processed the callback will not be run.
|
||||
pub fn run_with_handle<T>(
|
||||
id: Id,
|
||||
f: impl FnOnce(WindowHandle<'_>) -> T + Send + 'static,
|
||||
) -> Task<T>
|
||||
where
|
||||
T: Send + 'static,
|
||||
{
|
||||
task::oneshot(move |channel| {
|
||||
crate::Action::Window(Action::RunWithHandle(
|
||||
id,
|
||||
Box::new(move |handle| {
|
||||
let _ = channel.send(f(handle));
|
||||
}),
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
/// Captures a [`Screenshot`] from the window.
|
||||
pub fn screenshot(id: Id) -> Task<Screenshot> {
|
||||
task::oneshot(move |channel| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue