Merge pull request #1589 from Night-Hunter-NF/FetchWindowId
add action to get window id
This commit is contained in:
commit
c2a5f05924
3 changed files with 18 additions and 0 deletions
|
|
@ -76,6 +76,8 @@ pub enum Action<T> {
|
||||||
///
|
///
|
||||||
/// - **Web / Wayland:** Unsupported.
|
/// - **Web / Wayland:** Unsupported.
|
||||||
ChangeAlwaysOnTop(bool),
|
ChangeAlwaysOnTop(bool),
|
||||||
|
/// Fetch an identifier unique to the window.
|
||||||
|
FetchId(Box<dyn FnOnce(u64) -> T + 'static>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Action<T> {
|
impl<T> Action<T> {
|
||||||
|
|
@ -105,6 +107,7 @@ impl<T> Action<T> {
|
||||||
Self::ChangeAlwaysOnTop(on_top) => {
|
Self::ChangeAlwaysOnTop(on_top) => {
|
||||||
Action::ChangeAlwaysOnTop(on_top)
|
Action::ChangeAlwaysOnTop(on_top)
|
||||||
}
|
}
|
||||||
|
Self::FetchId(o) => Action::FetchId(Box::new(move |s| f(o(s)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -138,6 +141,7 @@ impl<T> fmt::Debug for Action<T> {
|
||||||
Self::ChangeAlwaysOnTop(on_top) => {
|
Self::ChangeAlwaysOnTop(on_top) => {
|
||||||
write!(f, "Action::AlwaysOnTop({on_top})")
|
write!(f, "Action::AlwaysOnTop({on_top})")
|
||||||
}
|
}
|
||||||
|
Self::FetchId(_) => write!(f, "Action::FetchId"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -794,6 +794,11 @@ pub fn run_command<A, E>(
|
||||||
window::Action::ChangeAlwaysOnTop(on_top) => {
|
window::Action::ChangeAlwaysOnTop(on_top) => {
|
||||||
window.set_always_on_top(on_top);
|
window.set_always_on_top(on_top);
|
||||||
}
|
}
|
||||||
|
window::Action::FetchId(tag) => {
|
||||||
|
proxy
|
||||||
|
.send_event(tag(window.id().into()))
|
||||||
|
.expect("Send message to event loop");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
command::Action::System(action) => match action {
|
command::Action::System(action) => match action {
|
||||||
system::Action::QueryInformation(_tag) => {
|
system::Action::QueryInformation(_tag) => {
|
||||||
|
|
|
||||||
|
|
@ -95,3 +95,12 @@ pub fn change_always_on_top<Message>(on_top: bool) -> Command<Message> {
|
||||||
on_top,
|
on_top,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetches an identifier unique to the window.
|
||||||
|
pub fn fetch_id<Message>(
|
||||||
|
f: impl FnOnce(u64) -> Message + 'static,
|
||||||
|
) -> Command<Message> {
|
||||||
|
Command::single(command::Action::Window(window::Action::FetchId(Box::new(
|
||||||
|
f,
|
||||||
|
))))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue