Merge pull request #965 from tarkah/feature/window-event-moved

Add window::Event::Moved
This commit is contained in:
Héctor Ramón 2021-07-27 08:40:49 +07:00 committed by GitHub
commit 1cef6a2a58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -3,6 +3,14 @@ use std::path::PathBuf;
/// A window-related event.
#[derive(PartialEq, Clone, Debug)]
pub enum Event {
/// A window was moved.
Moved {
/// The new logical x location of the window
x: i32,
/// The new logical y location of the window
y: i32,
},
/// A window was resized.
Resized {
/// The new width of the window (in units)

View file

@ -130,6 +130,12 @@ pub fn window_event(
WindowEvent::Touch(touch) => {
Some(Event::Touch(touch_event(*touch, scale_factor)))
}
WindowEvent::Moved(position) => {
let winit::dpi::LogicalPosition { x, y } =
position.to_logical(scale_factor);
Some(Event::Window(window::Event::Moved { x, y }))
}
_ => None,
}
}