diff options
author | 2024-02-07 10:40:06 +0100 | |
---|---|---|
committer | 2024-02-07 10:40:06 +0100 | |
commit | d3619b5f69e3688a9ea76b56a072e01f3ca9d9ab (patch) | |
tree | e25f711dfa6fff214d19a7d1c358f0928f2a538e /runtime/src/window/action.rs | |
parent | 6f97b62457d924ef690d736c1aabe658f9c5778b (diff) | |
parent | 2a3778daa349043f5b69a1b264feb5f00d3dd772 (diff) | |
download | iced-d3619b5f69e3688a9ea76b56a072e01f3ca9d9ab.tar.gz iced-d3619b5f69e3688a9ea76b56a072e01f3ca9d9ab.tar.bz2 iced-d3619b5f69e3688a9ea76b56a072e01f3ca9d9ab.zip |
Merge pull request #2200 from dtzxporter/run-window-callback
Provide native window access, via "fetch_native_handle" method on window.
Diffstat (limited to 'runtime/src/window/action.rs')
-rw-r--r-- | runtime/src/window/action.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs index 8b532569..86d58528 100644 --- a/runtime/src/window/action.rs +++ b/runtime/src/window/action.rs @@ -3,6 +3,8 @@ use crate::core::{Point, Size}; use crate::futures::MaybeSend; use crate::window::Screenshot; +use raw_window_handle::WindowHandle; + use std::fmt; /// An operation to be performed on some window. @@ -96,6 +98,8 @@ pub enum Action<T> { /// - **X11:** Has no universal guidelines for icon sizes, so you're at the whims of the WM. That /// said, it's usually in the same ballpark as on Windows. ChangeIcon(Id, Icon), + /// Runs the closure with the native window handle of the window with the given [`Id`]. + RunWithHandle(Id, Box<dyn FnOnce(&WindowHandle<'_>) -> T + 'static>), /// Screenshot the viewport of the window. Screenshot(Id, Box<dyn FnOnce(Screenshot) -> T + 'static>), } @@ -141,6 +145,9 @@ impl<T> Action<T> { Action::FetchId(id, Box::new(move |s| f(o(s)))) } Self::ChangeIcon(id, icon) => Action::ChangeIcon(id, icon), + Self::RunWithHandle(id, o) => { + Action::RunWithHandle(id, Box::new(move |s| f(o(s)))) + } Self::Screenshot(id, tag) => Action::Screenshot( id, Box::new(move |screenshot| f(tag(screenshot))), @@ -197,6 +204,9 @@ impl<T> fmt::Debug for Action<T> { Self::ChangeIcon(id, _icon) => { write!(f, "Action::ChangeIcon({id:?})") } + Self::RunWithHandle(id, _) => { + write!(f, "Action::RunWithHandle({id:?})") + } Self::Screenshot(id, _) => write!(f, "Action::Screenshot({id:?})"), } } |