-
-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: marc2332 <[email protected]> Co-Authored-By: Kirill Chibisov <[email protected]> Co-Authored-By: Marijn Suijten <[email protected]>
- Loading branch information
1 parent
c68d98f
commit aa67fca
Showing
9 changed files
with
365 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use raw_window_handle::{DisplayHandle, HandleError, HasDisplayHandle}; | ||
use winit::error::OsError; | ||
use winit::event_loop::{ActiveEventLoop, EventLoop}; | ||
use winit::window::{Window, WindowAttributes}; | ||
|
||
use crate::private::Sealed; | ||
|
||
/// [`ActiveEventLoop`] is the recommended way to interact with the event | ||
/// loop, but for compatibility purposes [`EventLoop`] is also supported | ||
/// although not recommended anymore as it has been deprecated by Winit. | ||
pub trait GlutinEventLoop: Sealed { | ||
/// Create the window. | ||
/// | ||
/// See [`ActiveEventLoop::create_window`] for details. | ||
fn create_window(&self, window_attributes: WindowAttributes) -> Result<Window, OsError>; | ||
|
||
/// Get a handle to the display controller of the windowing system. | ||
fn glutin_display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>; | ||
} | ||
|
||
impl Sealed for ActiveEventLoop {} | ||
|
||
impl GlutinEventLoop for ActiveEventLoop { | ||
fn create_window(&self, window_attributes: WindowAttributes) -> Result<Window, OsError> { | ||
self.create_window(window_attributes) | ||
} | ||
|
||
fn glutin_display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> { | ||
self.display_handle() | ||
} | ||
} | ||
|
||
impl<T> Sealed for EventLoop<T> {} | ||
|
||
impl<T> GlutinEventLoop for EventLoop<T> { | ||
#[allow(deprecated)] | ||
fn create_window(&self, window_attributes: WindowAttributes) -> Result<Window, OsError> { | ||
self.create_window(window_attributes) | ||
} | ||
|
||
fn glutin_display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> { | ||
self.display_handle() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
#![cfg(android_platform)] | ||
|
||
use winit::event_loop::EventLoopBuilder; | ||
use winit::event_loop::EventLoop; | ||
use winit::platform::android::EventLoopBuilderExtAndroid; | ||
|
||
#[no_mangle] | ||
fn android_main(app: winit::platform::android::activity::AndroidApp) { | ||
let event_loop = EventLoopBuilder::new().with_android_app(app).build().unwrap(); | ||
let event_loop = EventLoop::builder().with_android_app(app).build().unwrap(); | ||
glutin_examples::main(event_loop).unwrap() | ||
} |
Oops, something went wrong.