Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ piet-common = "=0.5.0"
kurbo = "0.8.2"

tracing = "0.1.22"
lazy_static = "1.4.0"
once_cell = "1.14.0"
time = "0.3.0"
cfg-if = "1.0.0"
instant = { version = "0.1.6", features = ["wasm-bindgen"] }
Expand Down
36 changes: 17 additions & 19 deletions druid-shell/src/backend/mac/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ use std::rc::Rc;
use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular};
use cocoa::base::{id, nil, NO, YES};
use cocoa::foundation::{NSArray, NSAutoreleasePool};
use lazy_static::lazy_static;
use objc::declare::ClassDecl;
use objc::runtime::{Class, Object, Sel};
use objc::{class, msg_send, sel, sel_impl};
use once_cell::sync::Lazy;

use crate::application::AppHandler;

Expand Down Expand Up @@ -158,24 +158,22 @@ struct AppDelegate(*const Class);
unsafe impl Sync for AppDelegate {}
unsafe impl Send for AppDelegate {}

lazy_static! {
static ref APP_DELEGATE: AppDelegate = unsafe {
let mut decl = ClassDecl::new("DruidAppDelegate", class!(NSObject))
.expect("App Delegate definition failed");
decl.add_ivar::<*mut c_void>(APP_HANDLER_IVAR);

decl.add_method(
sel!(applicationDidFinishLaunching:),
application_did_finish_launching as extern "C" fn(&mut Object, Sel, id),
);

decl.add_method(
sel!(handleMenuItem:),
handle_menu_item as extern "C" fn(&mut Object, Sel, id),
);
AppDelegate(decl.register())
};
}
static APP_DELEGATE: Lazy<AppDelegate> = Lazy::new(|| unsafe {
let mut decl = ClassDecl::new("DruidAppDelegate", class!(NSObject))
.expect("App Delegate definition failed");
decl.add_ivar::<*mut c_void>(APP_HANDLER_IVAR);

decl.add_method(
sel!(applicationDidFinishLaunching:),
application_did_finish_launching as extern "C" fn(&mut Object, Sel, id),
);

decl.add_method(
sel!(handleMenuItem:),
handle_menu_item as extern "C" fn(&mut Object, Sel, id),
);
AppDelegate(decl.register())
});

extern "C" fn application_did_finish_launching(_this: &mut Object, _: Sel, _notification: id) {
unsafe {
Expand Down
Loading