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

@@ -1,8 +1,12 @@
use std::sync::atomic::{AtomicBool, Ordering};
use winit_core::application::ApplicationHandler;
use winit_core::error::{EventLoopError, NotSupportedError};
use winit_core::event_loop::ActiveEventLoop as RootActiveEventLoop;
use winit_core::cursor::{CustomCursor as CoreCustomCursor, CustomCursorSource};
use winit_core::error::{EventLoopError, NotSupportedError, RequestError};
use winit_core::event_loop::{
ActiveEventLoop as RootActiveEventLoop, ControlFlow, DeviceEvents, EventLoopProvider,
EventLoopProxy, OwnedDisplayHandle,
};
use crate::{
HasMonitorPermissionFuture, MonitorPermissionFuture, PollStrategy, WaitUntilStrategy, backend,
@@ -77,3 +81,33 @@ impl EventLoop {
)
}
}
impl EventLoopProvider for EventLoop {
fn run_app<A: ApplicationHandler + 'static>(self, app: A) -> Result<(), EventLoopError> {
self.register_app(app);
Ok(())
}
fn create_proxy(&self) -> EventLoopProxy {
self.window_target().create_proxy()
}
fn owned_display_handle(&self) -> OwnedDisplayHandle {
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<CoreCustomCursor, RequestError> {
self.window_target().create_custom_cursor(custom_cursor)
}
}