Migrate from lazy_static to once_cell
This commit is contained in:
parent
4c39b3188c
commit
2c01e9e747
18 changed files with 477 additions and 519 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue