Rename fetch_native_handle to run_with_handle in window
This commit is contained in:
parent
7105992228
commit
f18a81451f
4 changed files with 30 additions and 27 deletions
|
|
@ -15,6 +15,8 @@ use crate::core::{Point, Size};
|
|||
use crate::futures::event;
|
||||
use crate::futures::Subscription;
|
||||
|
||||
pub use raw_window_handle;
|
||||
|
||||
use raw_window_handle::WindowHandle;
|
||||
|
||||
/// Subscribes to the frames of the window of the running application.
|
||||
|
|
@ -172,14 +174,14 @@ pub fn change_icon<Message>(id: Id, icon: Icon) -> Command<Message> {
|
|||
Command::single(command::Action::Window(Action::ChangeIcon(id, icon)))
|
||||
}
|
||||
|
||||
/// Requests access to the native window handle for the window with the given id.
|
||||
/// 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 fetch_native_handle<Message>(
|
||||
pub fn run_with_handle<Message>(
|
||||
id: Id,
|
||||
f: impl FnOnce(&WindowHandle<'_>) -> Message + 'static,
|
||||
) -> Command<Message> {
|
||||
Command::single(command::Action::Window(Action::FetchNativeHandle(
|
||||
Command::single(command::Action::Window(Action::RunWithHandle(
|
||||
id,
|
||||
Box::new(f),
|
||||
)))
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ pub enum Action<T> {
|
|||
/// said, it's usually in the same ballpark as on Windows.
|
||||
ChangeIcon(Id, Icon),
|
||||
/// Requests access to the windows native handle.
|
||||
FetchNativeHandle(Id, Box<dyn FnOnce(&WindowHandle<'_>) -> T + 'static>),
|
||||
RunWithHandle(Id, Box<dyn FnOnce(&WindowHandle<'_>) -> T + 'static>),
|
||||
/// Screenshot the viewport of the window.
|
||||
Screenshot(Id, Box<dyn FnOnce(Screenshot) -> T + 'static>),
|
||||
}
|
||||
|
|
@ -145,8 +145,8 @@ impl<T> Action<T> {
|
|||
Action::FetchId(id, Box::new(move |s| f(o(s))))
|
||||
}
|
||||
Self::ChangeIcon(id, icon) => Action::ChangeIcon(id, icon),
|
||||
Self::FetchNativeHandle(id, o) => {
|
||||
Action::FetchNativeHandle(id, Box::new(move |s| f(o(s))))
|
||||
Self::RunWithHandle(id, o) => {
|
||||
Action::RunWithHandle(id, Box::new(move |s| f(o(s))))
|
||||
}
|
||||
Self::Screenshot(id, tag) => Action::Screenshot(
|
||||
id,
|
||||
|
|
@ -204,8 +204,8 @@ impl<T> fmt::Debug for Action<T> {
|
|||
Self::ChangeIcon(id, _icon) => {
|
||||
write!(f, "Action::ChangeIcon({id:?})")
|
||||
}
|
||||
Self::FetchNativeHandle(id, _) => {
|
||||
write!(f, "Action::RequestNativeHandle({id:?})")
|
||||
Self::RunWithHandle(id, _) => {
|
||||
write!(f, "Action::RunWithHandle({id:?})")
|
||||
}
|
||||
Self::Screenshot(id, _) => write!(f, "Action::Screenshot({id:?})"),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue