mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-02 06:40:06 -04:00
Take IntoIterator in send_events()
This commit is contained in:
@@ -192,7 +192,7 @@ impl<T: 'static> Shared<T> {
|
|||||||
// Add a series of events to the event loop runner
|
// Add a series of events to the event loop runner
|
||||||
//
|
//
|
||||||
// It will determine if the event should be immediately sent to the user or buffered for later
|
// It will determine if the event should be immediately sent to the user or buffered for later
|
||||||
pub fn send_events(&self, events: impl Iterator<Item = Event<'static, T>>) {
|
pub fn send_events(&self, events: impl IntoIterator<Item = Event<'static, T>>) {
|
||||||
// If the event loop is closed, it should discard any new events
|
// If the event loop is closed, it should discard any new events
|
||||||
if self.is_closed() {
|
if self.is_closed() {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -278,8 +278,7 @@ impl<T> EventLoopWindowTarget<T> {
|
|||||||
let runner = self.runner.clone();
|
let runner = self.runner.clone();
|
||||||
|
|
||||||
move |pointer_id, position, delta| {
|
move |pointer_id, position, delta| {
|
||||||
runner.send_events(
|
runner.send_events([
|
||||||
[
|
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
window_id: RootWindowId(id),
|
window_id: RootWindowId(id),
|
||||||
event: WindowEvent::CursorMoved {
|
event: WindowEvent::CursorMoved {
|
||||||
@@ -293,9 +292,7 @@ impl<T> EventLoopWindowTarget<T> {
|
|||||||
delta: (delta.x, delta.y),
|
delta: (delta.x, delta.y),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -341,8 +338,7 @@ impl<T> EventLoopWindowTarget<T> {
|
|||||||
// A chorded button event may come in without any prior CursorMoved events,
|
// A chorded button event may come in without any prior CursorMoved events,
|
||||||
// therefore we should send a CursorMoved event to make sure that the
|
// therefore we should send a CursorMoved event to make sure that the
|
||||||
// user code has the correct cursor position.
|
// user code has the correct cursor position.
|
||||||
runner.send_events(
|
runner.send_events([
|
||||||
[
|
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
window_id: RootWindowId(id),
|
window_id: RootWindowId(id),
|
||||||
event: WindowEvent::CursorMoved {
|
event: WindowEvent::CursorMoved {
|
||||||
@@ -351,9 +347,7 @@ impl<T> EventLoopWindowTarget<T> {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
button_event,
|
button_event,
|
||||||
]
|
]);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
prevent_default,
|
prevent_default,
|
||||||
@@ -381,8 +375,7 @@ impl<T> EventLoopWindowTarget<T> {
|
|||||||
// A mouse down event may come in without any prior CursorMoved events,
|
// A mouse down event may come in without any prior CursorMoved events,
|
||||||
// therefore we should send a CursorMoved event to make sure that the
|
// therefore we should send a CursorMoved event to make sure that the
|
||||||
// user code has the correct cursor position.
|
// user code has the correct cursor position.
|
||||||
runner.send_events(
|
runner.send_events([
|
||||||
[
|
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
window_id: RootWindowId(id),
|
window_id: RootWindowId(id),
|
||||||
event: WindowEvent::CursorMoved {
|
event: WindowEvent::CursorMoved {
|
||||||
@@ -398,9 +391,7 @@ impl<T> EventLoopWindowTarget<T> {
|
|||||||
button,
|
button,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -445,8 +436,7 @@ impl<T> EventLoopWindowTarget<T> {
|
|||||||
// A mouse up event may come in without any prior CursorMoved events,
|
// A mouse up event may come in without any prior CursorMoved events,
|
||||||
// therefore we should send a CursorMoved event to make sure that the
|
// therefore we should send a CursorMoved event to make sure that the
|
||||||
// user code has the correct cursor position.
|
// user code has the correct cursor position.
|
||||||
runner.send_events(
|
runner.send_events([
|
||||||
[
|
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
window_id: RootWindowId(id),
|
window_id: RootWindowId(id),
|
||||||
event: WindowEvent::CursorMoved {
|
event: WindowEvent::CursorMoved {
|
||||||
@@ -462,9 +452,7 @@ impl<T> EventLoopWindowTarget<T> {
|
|||||||
button,
|
button,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user