Add fetch_location command to window module
This commit is contained in:
parent
6c00e615b9
commit
59885e9a36
4 changed files with 51 additions and 0 deletions
|
|
@ -773,6 +773,20 @@ pub fn run_command<A, C, E>(
|
|||
y: position.y,
|
||||
});
|
||||
}
|
||||
window::Action::FetchLocation(_id, callback) => {
|
||||
let position = window
|
||||
.inner_position()
|
||||
.map(|p| {
|
||||
let pos =
|
||||
p.to_logical::<f32>(window.scale_factor());
|
||||
crate::core::Point::new(pos.x, pos.y)
|
||||
})
|
||||
.ok();
|
||||
|
||||
proxy
|
||||
.send_event(callback(position))
|
||||
.expect("Send message to event loop");
|
||||
}
|
||||
window::Action::ChangeMode(_id, mode) => {
|
||||
window.set_visible(conversion::visible(mode));
|
||||
window.set_fullscreen(conversion::fullscreen(
|
||||
|
|
|
|||
|
|
@ -1003,6 +1003,24 @@ fn run_command<A, C, E>(
|
|||
);
|
||||
}
|
||||
}
|
||||
window::Action::FetchLocation(id, callback) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
let position = window
|
||||
.raw
|
||||
.inner_position()
|
||||
.map(|p| {
|
||||
let pos = p.to_logical::<f32>(
|
||||
window.raw.scale_factor(),
|
||||
);
|
||||
crate::core::Point::new(pos.x, pos.y)
|
||||
})
|
||||
.ok();
|
||||
|
||||
proxy
|
||||
.send_event(callback(position))
|
||||
.expect("Send message to event loop");
|
||||
}
|
||||
}
|
||||
window::Action::ChangeMode(id, mode) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
window.raw.set_visible(conversion::visible(mode));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue