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

@ -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(),