Skip to content

Commit 9f75f01

Browse files
n1ght-hunterhecrj
authored andcommitted
add action to get window id
1 parent b9b0a9a commit 9f75f01

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

native/src/window/action.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ pub enum Action<T> {
7676
///
7777
/// - **Web / Wayland:** Unsupported.
7878
ChangeAlwaysOnTop(bool),
79+
/// Fetch an identifier unique to the window.
80+
FetchId(Box<dyn FnOnce(u64) -> T + 'static>),
7981
}
8082

8183
impl<T> Action<T> {
@@ -105,6 +107,7 @@ impl<T> Action<T> {
105107
Self::ChangeAlwaysOnTop(on_top) => {
106108
Action::ChangeAlwaysOnTop(on_top)
107109
}
110+
Self::FetchId(o) => Action::FetchId(Box::new(move |s| f(o(s)))),
108111
}
109112
}
110113
}
@@ -138,6 +141,7 @@ impl<T> fmt::Debug for Action<T> {
138141
Self::ChangeAlwaysOnTop(on_top) => {
139142
write!(f, "Action::AlwaysOnTop({on_top})")
140143
}
144+
Self::FetchId(_) => write!(f, "Action::FetchId"),
141145
}
142146
}
143147
}

winit/src/application.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,11 @@ pub fn run_command<A, E>(
794794
window::Action::ChangeAlwaysOnTop(on_top) => {
795795
window.set_always_on_top(on_top);
796796
}
797+
window::Action::FetchId(tag) => {
798+
proxy
799+
.send_event(tag(window.id().into()))
800+
.expect("Send message to event loop");
801+
}
797802
},
798803
command::Action::System(action) => match action {
799804
system::Action::QueryInformation(_tag) => {

0 commit comments

Comments
 (0)