chore: implement EventLoopProvider in each winit-* crate

This commit is contained in:
Kirill Chibisov
2026-07-27 21:50:29 +09:00
parent d74e5c51d1
commit 42366231b0
10 changed files with 326 additions and 40 deletions

View File

@@ -74,8 +74,8 @@ use winit_core::event::{
use winit_core::event_loop::pump_events::PumpStatus;
use winit_core::event_loop::{
ActiveEventLoop as RootActiveEventLoop, AsyncRequestSerial, ControlFlow, DeviceEvents,
DndAction, DragIcon, EventLoopProxy as RootEventLoopProxy, EventLoopProxyProvider,
OwnedDisplayHandle as CoreOwnedDisplayHandle,
DndAction, DragIcon, EventLoopProvider, EventLoopProxy as RootEventLoopProxy,
EventLoopProxyProvider, OwnedDisplayHandle as CoreOwnedDisplayHandle,
};
use winit_core::keyboard::ModifiersState;
use winit_core::monitor::{Fullscreen, MonitorHandle as CoreMonitorHandle};
@@ -392,6 +392,41 @@ impl EventLoop {
}
}
impl EventLoopProvider for EventLoop {
fn run_app<A: ApplicationHandler + 'static>(
mut self,
mut app: A,
) -> Result<(), EventLoopError> {
let result = self.run_app_on_demand(&mut app);
// SAFETY: unsure that the state is dropped before the exit from the event loop.
drop(app);
result
}
fn create_proxy(&self) -> RootEventLoopProxy {
self.window_target().create_proxy()
}
fn owned_display_handle(&self) -> CoreOwnedDisplayHandle {
self.window_target().owned_display_handle()
}
fn listen_device_events(&self, allowed: DeviceEvents) {
self.window_target().listen_device_events(allowed);
}
fn set_control_flow(&self, control_flow: ControlFlow) {
self.window_target().set_control_flow(control_flow);
}
fn create_custom_cursor(
&self,
custom_cursor: CustomCursorSource,
) -> Result<CustomCursor, RequestError> {
self.window_target().create_custom_cursor(custom_cursor)
}
}
impl Drop for EventLoop {
fn drop(&mut self) {
unsafe {