Implement ApplicationHandler::can_create|destroy_surfaces() (#3765)

This commit is contained in:
daxpedda 2024-06-30 00:41:57 +02:00 committed by GitHub
parent a0d69c782a
commit 75ce71f05a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 178 additions and 114 deletions

View file

@ -87,6 +87,7 @@ fn handle_event<A: ApplicationHandler>(app: &mut A, target: &RootActiveEventLoop
Event::UserWakeUp => app.proxy_wake_up(target),
Event::Suspended => app.suspended(target),
Event::Resumed => app.resumed(target),
Event::CreateSurfaces => app.can_create_surfaces(target),
Event::AboutToWait => app.about_to_wait(target),
Event::LoopExiting => app.exiting(target),
Event::MemoryWarning => app.memory_warning(target),

View file

@ -441,9 +441,11 @@ impl Shared {
}
pub fn init(&self) {
// NB: For consistency all platforms must emit a 'resumed' event even though web
// applications don't themselves have a formal suspend/resume lifecycle.
self.run_until_cleared([Event::NewEvents(StartCause::Init), Event::Resumed].into_iter());
// NB: For consistency all platforms must call `can_create_surfaces` even though web
// applications don't themselves have a formal surface destroy/create lifecycle.
self.run_until_cleared(
[Event::NewEvents(StartCause::Init), Event::CreateSurfaces].into_iter(),
);
}
// Run the polling logic for the Poll ControlFlow, which involves clearing the queue