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:
Kirill Chibisov 2023-07-31 00:39:01 +04:00 committed by GitHub
parent 2b2dd6b65d
commit 9ac3259a79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 252 additions and 429 deletions

View file

@ -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)
}
}