mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 13:31:29 +11:00
Document Android raw_window_handle requirements (#1749)
* Add docs describing raw_winow_handle on android * Run cargo fmt * Change raw_window_handle panic to give more info
This commit is contained in:
parent
33fb62bb25
commit
be850e483a
|
@ -505,7 +505,7 @@ impl Window {
|
||||||
let a_native_window = if let Some(native_window) = ndk_glue::native_window().as_ref() {
|
let a_native_window = if let Some(native_window) = ndk_glue::native_window().as_ref() {
|
||||||
unsafe { native_window.ptr().as_mut() as *mut _ as *mut _ }
|
unsafe { native_window.ptr().as_mut() as *mut _ as *mut _ }
|
||||||
} else {
|
} else {
|
||||||
panic!("native window null");
|
panic!("Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events.");
|
||||||
};
|
};
|
||||||
let mut handle = raw_window_handle::android::AndroidHandle::empty();
|
let mut handle = raw_window_handle::android::AndroidHandle::empty();
|
||||||
handle.a_native_window = a_native_window;
|
handle.a_native_window = a_native_window;
|
||||||
|
|
|
@ -784,6 +784,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl raw_window_handle::HasRawWindowHandle for Window {
|
unsafe impl raw_window_handle::HasRawWindowHandle for Window {
|
||||||
|
/// Returns a `raw_window_handle::RawWindowHandle` for the Window
|
||||||
|
///
|
||||||
|
/// ## Platform-specific
|
||||||
|
///
|
||||||
|
/// - **Android:** Only available after receiving the Resumed event and before Suspended. *If you*
|
||||||
|
/// *try to get the handle outside of that period, this function will panic*!
|
||||||
fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
|
fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
|
||||||
self.window.raw_window_handle()
|
self.window.raw_window_handle()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue