Skip to content

Commit

Permalink
formated
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ght-hunter committed Feb 22, 2024
1 parent 06e26df commit 4c60c15
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion runtime/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ pub fn fetch_location<Message>(
id: Id,
f: impl FnOnce(Option<Point>) -> Message + 'static,
) -> Command<Message> {
Command::single(command::Action::Window(Action::FetchLocation(id, Box::new(f))))
Command::single(command::Action::Window(Action::FetchLocation(
id,
Box::new(f),
)))
}

/// Changes the [`Mode`] of the window.
Expand Down
12 changes: 8 additions & 4 deletions winit/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,14 @@ pub fn run_command<A, C, E>(
});
}
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();
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))
Expand Down
3 changes: 2 additions & 1 deletion winit/src/multi_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,8 @@ fn run_command<A, C, E>(
window.raw.scale_factor(),
);
crate::core::Point::new(pos.x, pos.y)
}).ok();
})
.ok();

proxy
.send_event(callback(position))
Expand Down

0 comments on commit 4c60c15

Please sign in to comment.