mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Remove lifetime from the Event
Lifetimes don't work nicely when dealing with multithreaded environments in the current design of the existing winit's event handling model, so remove it in favor of `InnerSizeWriter` fences passed to client, so they could try to update the size. Fixes #1387.
This commit is contained in:
@@ -31,7 +31,7 @@ impl<T> EventLoop<T> {
|
||||
|
||||
pub fn run<F>(self, event_handler: F) -> !
|
||||
where
|
||||
F: 'static + FnMut(Event<'_, T>, &RootEventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
F: 'static + FnMut(Event<T>, &RootEventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
{
|
||||
self.spawn_inner(event_handler, false);
|
||||
|
||||
@@ -46,14 +46,14 @@ impl<T> EventLoop<T> {
|
||||
|
||||
pub fn spawn<F>(self, event_handler: F)
|
||||
where
|
||||
F: 'static + FnMut(Event<'_, T>, &RootEventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
F: 'static + FnMut(Event<T>, &RootEventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
{
|
||||
self.spawn_inner(event_handler, true);
|
||||
}
|
||||
|
||||
fn spawn_inner<F>(self, mut event_handler: F, event_loop_recreation: bool)
|
||||
where
|
||||
F: 'static + FnMut(Event<'_, T>, &RootEventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
F: 'static + FnMut(Event<T>, &RootEventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
{
|
||||
let target = RootEventLoopWindowTarget {
|
||||
p: self.elw.p.clone(),
|
||||
|
||||
@@ -24,7 +24,7 @@ use web_time::{Duration, Instant};
|
||||
|
||||
pub struct Shared<T: 'static>(Rc<Execution<T>>);
|
||||
|
||||
pub(super) type EventHandler<T> = dyn FnMut(Event<'_, T>, &mut ControlFlow);
|
||||
pub(super) type EventHandler<T> = dyn FnMut(Event<T>, &mut ControlFlow);
|
||||
|
||||
impl<T> Clone for Shared<T> {
|
||||
fn clone(&self) -> Self {
|
||||
@@ -748,7 +748,7 @@ impl<T: 'static> Shared<T> {
|
||||
}
|
||||
|
||||
pub(crate) enum EventWrapper<T: 'static> {
|
||||
Event(Event<'static, T>),
|
||||
Event(Event<T>),
|
||||
ScaleChange {
|
||||
canvas: Weak<RefCell<backend::Canvas>>,
|
||||
size: PhysicalSize<u32>,
|
||||
@@ -756,8 +756,8 @@ pub(crate) enum EventWrapper<T: 'static> {
|
||||
},
|
||||
}
|
||||
|
||||
impl<T> From<Event<'static, T>> for EventWrapper<T> {
|
||||
fn from(value: Event<'static, T>) -> Self {
|
||||
impl<T> From<Event<T>> for EventWrapper<T> {
|
||||
fn from(value: Event<T>) -> Self {
|
||||
Self::Event(value)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user