summaryrefslogtreecommitdiffstats
path: root/winit/src/conversion.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-06-11 20:22:44 +0200
committerLibravatar GitHub <noreply@github.com>2024-06-11 20:22:44 +0200
commite6d0b3bda5042a1017a5944a5227c97e0ed6caf9 (patch)
tree916f837424c3baeacc1e0f43b02bc892a3445cbb /winit/src/conversion.rs
parentbda01567d59c00e42e5a208ee6d9ec4153d5c195 (diff)
parent6ea7846d88915f8d820c5126d7757f1346234522 (diff)
downloadiced-e6d0b3bda5042a1017a5944a5227c97e0ed6caf9.tar.gz
iced-e6d0b3bda5042a1017a5944a5227c97e0ed6caf9.tar.bz2
iced-e6d0b3bda5042a1017a5944a5227c97e0ed6caf9.zip
Merge pull request #2456 from iced-rs/window-id-in-event-subscriptions
Introduce `window::Id` to `Event` subscriptions
Diffstat (limited to 'winit/src/conversion.rs')
-rw-r--r--winit/src/conversion.rs35
1 files changed, 14 insertions, 21 deletions
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index ea33e610..79fcf92e 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -126,7 +126,6 @@ pub fn window_attributes(
/// Converts a winit window event into an iced event.
pub fn window_event(
- id: window::Id,
event: winit::event::WindowEvent,
scale_factor: f64,
modifiers: winit::keyboard::ModifiersState,
@@ -137,16 +136,13 @@ pub fn window_event(
WindowEvent::Resized(new_size) => {
let logical_size = new_size.to_logical(scale_factor);
- Some(Event::Window(
- id,
- window::Event::Resized {
- width: logical_size.width,
- height: logical_size.height,
- },
- ))
+ Some(Event::Window(window::Event::Resized {
+ width: logical_size.width,
+ height: logical_size.height,
+ }))
}
WindowEvent::CloseRequested => {
- Some(Event::Window(id, window::Event::CloseRequested))
+ Some(Event::Window(window::Event::CloseRequested))
}
WindowEvent::CursorMoved { position, .. } => {
let position = position.to_logical::<f64>(scale_factor);
@@ -264,22 +260,19 @@ pub fn window_event(
self::modifiers(new_modifiers.state()),
)))
}
- WindowEvent::Focused(focused) => Some(Event::Window(
- id,
- if focused {
- window::Event::Focused
- } else {
- window::Event::Unfocused
- },
- )),
+ WindowEvent::Focused(focused) => Some(Event::Window(if focused {
+ window::Event::Focused
+ } else {
+ window::Event::Unfocused
+ })),
WindowEvent::HoveredFile(path) => {
- Some(Event::Window(id, window::Event::FileHovered(path.clone())))
+ Some(Event::Window(window::Event::FileHovered(path.clone())))
}
WindowEvent::DroppedFile(path) => {
- Some(Event::Window(id, window::Event::FileDropped(path.clone())))
+ Some(Event::Window(window::Event::FileDropped(path.clone())))
}
WindowEvent::HoveredFileCancelled => {
- Some(Event::Window(id, window::Event::FilesHoveredLeft))
+ Some(Event::Window(window::Event::FilesHoveredLeft))
}
WindowEvent::Touch(touch) => {
Some(Event::Touch(touch_event(touch, scale_factor)))
@@ -288,7 +281,7 @@ pub fn window_event(
let winit::dpi::LogicalPosition { x, y } =
position.to_logical(scale_factor);
- Some(Event::Window(id, window::Event::Moved { x, y }))
+ Some(Event::Window(window::Event::Moved { x, y }))
}
_ => None,
}