iOS os version checking around certain APIs (#1094)
* iOS os version checking * iOS, fix some incorrect msg_send return types * address nits, and fix OS version check for unsupported os versions * source for 60fps guarantee
This commit is contained in:
parent
7b707e7d75
commit
f53683f01f
9 changed files with 209 additions and 81 deletions
|
|
@ -23,8 +23,7 @@ use crate::platform_impl::platform::{
|
|||
CFRunLoopActivity, CFRunLoopAddObserver, CFRunLoopAddSource, CFRunLoopGetMain,
|
||||
CFRunLoopObserverCreate, CFRunLoopObserverRef, CFRunLoopSourceContext,
|
||||
CFRunLoopSourceCreate, CFRunLoopSourceInvalidate, CFRunLoopSourceRef,
|
||||
CFRunLoopSourceSignal, CFRunLoopWakeUp, NSOperatingSystemVersion, NSString,
|
||||
UIApplicationMain, UIUserInterfaceIdiom,
|
||||
CFRunLoopSourceSignal, CFRunLoopWakeUp, NSString, UIApplicationMain, UIUserInterfaceIdiom,
|
||||
},
|
||||
monitor, view, MonitorHandle,
|
||||
};
|
||||
|
|
@ -32,13 +31,6 @@ use crate::platform_impl::platform::{
|
|||
pub struct EventLoopWindowTarget<T: 'static> {
|
||||
receiver: Receiver<T>,
|
||||
sender_to_clone: Sender<T>,
|
||||
capabilities: Capabilities,
|
||||
}
|
||||
|
||||
impl<T: 'static> EventLoopWindowTarget<T> {
|
||||
pub fn capabilities(&self) -> &Capabilities {
|
||||
&self.capabilities
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EventLoop<T: 'static> {
|
||||
|
|
@ -64,18 +56,11 @@ impl<T: 'static> EventLoop<T> {
|
|||
// this line sets up the main run loop before `UIApplicationMain`
|
||||
setup_control_flow_observers();
|
||||
|
||||
let version: NSOperatingSystemVersion = unsafe {
|
||||
let process_info: id = msg_send![class!(NSProcessInfo), processInfo];
|
||||
msg_send![process_info, operatingSystemVersion]
|
||||
};
|
||||
let capabilities = version.into();
|
||||
|
||||
EventLoop {
|
||||
window_target: RootEventLoopWindowTarget {
|
||||
p: EventLoopWindowTarget {
|
||||
receiver,
|
||||
sender_to_clone,
|
||||
capabilities,
|
||||
},
|
||||
_marker: PhantomData,
|
||||
},
|
||||
|
|
@ -296,20 +281,3 @@ pub unsafe fn get_idiom() -> Idiom {
|
|||
let raw_idiom: UIUserInterfaceIdiom = msg_send![device, userInterfaceIdiom];
|
||||
raw_idiom.into()
|
||||
}
|
||||
|
||||
pub struct Capabilities {
|
||||
pub supports_safe_area: bool,
|
||||
}
|
||||
|
||||
impl From<NSOperatingSystemVersion> for Capabilities {
|
||||
fn from(os_version: NSOperatingSystemVersion) -> Capabilities {
|
||||
assert!(
|
||||
os_version.major >= 8,
|
||||
"`winit` current requires iOS version 8 or greater"
|
||||
);
|
||||
|
||||
let supports_safe_area = os_version.major >= 11;
|
||||
|
||||
Capabilities { supports_safe_area }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue