glutin_winit/
event_loop.rs1use raw_window_handle::{DisplayHandle, HandleError, HasDisplayHandle};
2use winit::error::OsError;
3use winit::event_loop::{ActiveEventLoop, EventLoop};
4use winit::window::{Window, WindowAttributes};
5
6use crate::private::Sealed;
7
8pub trait GlutinEventLoop: Sealed {
12 fn create_window(&self, window_attributes: WindowAttributes) -> Result<Window, OsError>;
16
17 fn glutin_display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>;
19}
20
21impl Sealed for ActiveEventLoop {}
22
23impl GlutinEventLoop for ActiveEventLoop {
24 fn create_window(&self, window_attributes: WindowAttributes) -> Result<Window, OsError> {
25 self.create_window(window_attributes)
26 }
27
28 fn glutin_display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> {
29 self.display_handle()
30 }
31}
32
33impl<T> Sealed for EventLoop<T> {}
34
35impl<T> GlutinEventLoop for EventLoop<T> {
36 #[allow(deprecated)]
37 fn create_window(&self, window_attributes: WindowAttributes) -> Result<Window, OsError> {
38 self.create_window(window_attributes)
39 }
40
41 fn glutin_display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> {
42 self.display_handle()
43 }
44}