mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 04:40:04 -04:00
chore: implement EventLoopProvider in each winit-* crate
This commit is contained in:
@@ -25,7 +25,7 @@ use winit_core::event::{DeviceId, StartCause, WindowEvent};
|
||||
use winit_core::event_loop::pump_events::PumpStatus;
|
||||
use winit_core::event_loop::{
|
||||
ActiveEventLoop as RootActiveEventLoop, AsyncRequestSerial, ControlFlow, DeviceEvents,
|
||||
DndAction, EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider,
|
||||
DndAction, EventLoopProvider, EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider,
|
||||
OwnedDisplayHandle as CoreOwnedDisplayHandle,
|
||||
};
|
||||
use winit_core::monitor::MonitorHandle as CoreMonitorHandle;
|
||||
@@ -647,6 +647,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) -> CoreEventLoopProxy {
|
||||
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<CoreCustomCursor, RequestError> {
|
||||
self.window_target().create_custom_cursor(custom_cursor)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsFd for EventLoop {
|
||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
self.event_loop.as_fd()
|
||||
|
||||
Reference in New Issue
Block a user