summaryrefslogtreecommitdiffstats
path: root/winit
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-27 22:02:23 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-27 22:06:20 +0100
commite23e93218c3b67a00637ea7a3a190c9b28379665 (patch)
tree5e55bae1e97b51536070b561389f766429354fa1 /winit
parent4d3afe2f0c6d42bb86248c1dbf5c5188e2b9e9ba (diff)
downloadiced-e23e93218c3b67a00637ea7a3a190c9b28379665.tar.gz
iced-e23e93218c3b67a00637ea7a3a190c9b28379665.tar.bz2
iced-e23e93218c3b67a00637ea7a3a190c9b28379665.zip
Convert `WindowEvent` from a reference in `iced_winit`
Diffstat (limited to 'winit')
-rw-r--r--winit/src/application.rs2
-rw-r--r--winit/src/conversion.rs24
2 files changed, 13 insertions, 13 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs
index 891b8f12..a647a1b6 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -378,7 +378,7 @@ pub trait Application: Sized {
}
if let Some(event) = conversion::window_event(
- window_event,
+ &window_event,
size.scale_factor(),
modifiers,
) {
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index 74852876..debaf535 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -1,4 +1,4 @@
-//! Convert [`winit`] types to [`iced_native`] types, and viceversa.
+//! Convert [`winit`] types into [`iced_native`] types, and viceversa.
//!
//! [`winit`]: https://github.com/rust-windowing/winit
//! [`iced_native`]: https://github.com/hecrj/iced/tree/master/native
@@ -12,7 +12,7 @@ use crate::{
/// Converts a winit window event into an iced event.
pub fn window_event(
- event: winit::event::WindowEvent<'_>,
+ event: &winit::event::WindowEvent<'_>,
scale_factor: f64,
modifiers: winit::event::ModifiersState,
) -> Option<Event> {
@@ -37,16 +37,16 @@ pub fn window_event(
}
WindowEvent::MouseInput { button, state, .. } => {
Some(Event::Mouse(mouse::Event::Input {
- button: mouse_button(button),
- state: button_state(state),
+ button: mouse_button(*button),
+ state: button_state(*state),
}))
}
WindowEvent::MouseWheel { delta, .. } => match delta {
winit::event::MouseScrollDelta::LineDelta(delta_x, delta_y) => {
Some(Event::Mouse(mouse::Event::WheelScrolled {
delta: mouse::ScrollDelta::Lines {
- x: delta_x,
- y: delta_y,
+ x: *delta_x,
+ y: *delta_y,
},
}))
}
@@ -59,8 +59,8 @@ pub fn window_event(
}))
}
},
- WindowEvent::ReceivedCharacter(c) if !is_private_use_character(c) => {
- Some(Event::Keyboard(keyboard::Event::CharacterReceived(c)))
+ WindowEvent::ReceivedCharacter(c) if !is_private_use_character(*c) => {
+ Some(Event::Keyboard(keyboard::Event::CharacterReceived(*c)))
}
WindowEvent::KeyboardInput {
input:
@@ -71,15 +71,15 @@ pub fn window_event(
},
..
} => Some(Event::Keyboard(keyboard::Event::Input {
- key_code: key_code(virtual_keycode),
- state: button_state(state),
+ key_code: key_code(*virtual_keycode),
+ state: button_state(*state),
modifiers: modifiers_state(modifiers),
})),
WindowEvent::HoveredFile(path) => {
- Some(Event::Window(window::Event::FileHovered(path)))
+ Some(Event::Window(window::Event::FileHovered(path.clone())))
}
WindowEvent::DroppedFile(path) => {
- Some(Event::Window(window::Event::FileDropped(path)))
+ Some(Event::Window(window::Event::FileDropped(path.clone())))
}
WindowEvent::HoveredFileCancelled => {
Some(Event::Window(window::Event::FilesHoveredLeft))