mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 23:23:14 -04:00
Migrate from lazy_static to once_cell
This commit is contained in:
@@ -46,6 +46,7 @@ use objc::{
|
||||
rc::autoreleasepool,
|
||||
runtime::{Class, Object, Sel, BOOL, NO, YES},
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct WindowId(pub usize);
|
||||
@@ -246,32 +247,30 @@ struct WindowClass(*const Class);
|
||||
unsafe impl Send for WindowClass {}
|
||||
unsafe impl Sync for WindowClass {}
|
||||
|
||||
lazy_static! {
|
||||
static ref WINDOW_CLASS: WindowClass = unsafe {
|
||||
let window_superclass = class!(NSWindow);
|
||||
let mut decl = ClassDecl::new("WinitWindow", window_superclass).unwrap();
|
||||
static WINDOW_CLASS: Lazy<WindowClass> = Lazy::new(|| unsafe {
|
||||
let window_superclass = class!(NSWindow);
|
||||
let mut decl = ClassDecl::new("WinitWindow", window_superclass).unwrap();
|
||||
|
||||
pub extern "C" fn can_become_main_window(_: &Object, _: Sel) -> BOOL {
|
||||
trace_scope!("canBecomeMainWindow");
|
||||
YES
|
||||
}
|
||||
pub extern "C" fn can_become_main_window(_: &Object, _: Sel) -> BOOL {
|
||||
trace_scope!("canBecomeMainWindow");
|
||||
YES
|
||||
}
|
||||
|
||||
pub extern "C" fn can_become_key_window(_: &Object, _: Sel) -> BOOL {
|
||||
trace_scope!("canBecomeKeyWindow");
|
||||
YES
|
||||
}
|
||||
pub extern "C" fn can_become_key_window(_: &Object, _: Sel) -> BOOL {
|
||||
trace_scope!("canBecomeKeyWindow");
|
||||
YES
|
||||
}
|
||||
|
||||
decl.add_method(
|
||||
sel!(canBecomeMainWindow),
|
||||
can_become_main_window as extern "C" fn(&Object, Sel) -> BOOL,
|
||||
);
|
||||
decl.add_method(
|
||||
sel!(canBecomeKeyWindow),
|
||||
can_become_key_window as extern "C" fn(&Object, Sel) -> BOOL,
|
||||
);
|
||||
WindowClass(decl.register())
|
||||
};
|
||||
}
|
||||
decl.add_method(
|
||||
sel!(canBecomeMainWindow),
|
||||
can_become_main_window as extern "C" fn(&Object, Sel) -> BOOL,
|
||||
);
|
||||
decl.add_method(
|
||||
sel!(canBecomeKeyWindow),
|
||||
can_become_key_window as extern "C" fn(&Object, Sel) -> BOOL,
|
||||
);
|
||||
WindowClass(decl.register())
|
||||
});
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct SharedState {
|
||||
|
||||
Reference in New Issue
Block a user