This commit is contained in:
Antonio Scandurra 2022-09-13 14:50:18 +02:00
parent a34eaa3606
commit b3dd09a0f2

View file

@ -5,8 +5,8 @@ use crate::{
}; };
use cocoa::{ use cocoa::{
appkit::{ appkit::{
NSApplication, NSButton, NSSquareStatusItemLength, NSStatusBar, NSStatusItem, NSView, NSApplication, NSButton, NSEventMask, NSSquareStatusItemLength, NSStatusBar, NSStatusItem,
NSViewHeightSizable, NSViewWidthSizable, NSWindow, NSView, NSViewHeightSizable, NSViewWidthSizable, NSWindow,
}, },
base::{id, nil, YES}, base::{id, nil, YES},
foundation::{NSSize, NSUInteger}, foundation::{NSSize, NSUInteger},
@ -32,9 +32,6 @@ use std::{
static mut HANDLER_CLASS: *const Class = ptr::null(); static mut HANDLER_CLASS: *const Class = ptr::null();
const STATE_IVAR: &str = "state"; const STATE_IVAR: &str = "state";
#[allow(non_upper_case_globals)]
const NSEventMaskAny: NSUInteger = NSUInteger::MAX;
#[ctor] #[ctor]
unsafe fn build_classes() { unsafe fn build_classes() {
HANDLER_CLASS = { HANDLER_CLASS = {
@ -82,7 +79,7 @@ impl StatusItem {
.set_ivar(STATE_IVAR, Weak::into_raw(state.clone()) as *const c_void); .set_ivar(STATE_IVAR, Weak::into_raw(state.clone()) as *const c_void);
button.setTarget_(*event_handler); button.setTarget_(*event_handler);
button.setAction_(sel!(handleEvent)); button.setAction_(sel!(handleEvent));
let _: () = msg_send![button, sendActionOn: NSEventMaskAny]; let _: () = msg_send![button, sendActionOn: NSEventMask::NSAnyEventMask];
RefCell::new(StatusItemState { RefCell::new(StatusItemState {
native_item, native_item,