Update objc2 crates (#3634)
Changes relevant to Winit: - `icrate` has been deprecated in favour of separate crates per framework, in our case `objc2-foundation` and `objc2-app-kit` (and in the future `objc2-ui-kit` on iOS). - Moved `MainThreadMarker::run_on_main` to free-standing function `run_on_main`. - Changed how features work, this should result in less code that we need to compile. - Enums are now real structs instead of type-aliases and free constants.
This commit is contained in:
parent
575d978202
commit
259e868c05
38 changed files with 289 additions and 270 deletions
97
Cargo.toml
97
Cargo.toml
|
|
@ -88,58 +88,71 @@ ndk-sys = "0.5.0"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
|
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
|
||||||
core-foundation = "0.9.3"
|
core-foundation = "0.9.3"
|
||||||
objc2 = "0.5.0"
|
objc2 = "0.5.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
core-graphics = "0.23.1"
|
core-graphics = "0.23.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies.icrate]
|
[target.'cfg(target_os = "macos")'.dependencies.objc2-foundation]
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
features = [
|
features = [
|
||||||
"dispatch",
|
"dispatch",
|
||||||
"Foundation",
|
"NSArray",
|
||||||
"Foundation_NSArray",
|
"NSAttributedString",
|
||||||
"Foundation_NSAttributedString",
|
"NSData",
|
||||||
"Foundation_NSMutableAttributedString",
|
"NSDictionary",
|
||||||
"Foundation_NSData",
|
"NSEnumerator",
|
||||||
"Foundation_NSDictionary",
|
"NSObjCRuntime",
|
||||||
"Foundation_NSString",
|
"NSString",
|
||||||
"Foundation_NSProcessInfo",
|
"NSPathUtilities",
|
||||||
"Foundation_NSThread",
|
"NSProcessInfo",
|
||||||
"Foundation_NSNumber",
|
"NSThread",
|
||||||
"AppKit",
|
"NSValue",
|
||||||
"AppKit_NSAppearance",
|
|
||||||
"AppKit_NSApplication",
|
|
||||||
"AppKit_NSBitmapImageRep",
|
|
||||||
"AppKit_NSButton",
|
|
||||||
"AppKit_NSColor",
|
|
||||||
"AppKit_NSControl",
|
|
||||||
"AppKit_NSCursor",
|
|
||||||
"AppKit_NSEvent",
|
|
||||||
"AppKit_NSGraphicsContext",
|
|
||||||
"AppKit_NSImage",
|
|
||||||
"AppKit_NSImageRep",
|
|
||||||
"AppKit_NSMenu",
|
|
||||||
"AppKit_NSMenuItem",
|
|
||||||
"AppKit_NSPasteboard",
|
|
||||||
"AppKit_NSResponder",
|
|
||||||
"AppKit_NSScreen",
|
|
||||||
"AppKit_NSTextInputContext",
|
|
||||||
"AppKit_NSView",
|
|
||||||
"AppKit_NSWindow",
|
|
||||||
"AppKit_NSWindowTabGroup",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[target.'cfg(target_os = "ios")'.dependencies.icrate]
|
[target.'cfg(target_os = "macos")'.dependencies.objc2-app-kit]
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
|
features = [
|
||||||
|
"NSAppearance",
|
||||||
|
"NSApplication",
|
||||||
|
"NSBitmapImageRep",
|
||||||
|
"NSButton",
|
||||||
|
"NSColor",
|
||||||
|
"NSControl",
|
||||||
|
"NSCursor",
|
||||||
|
"NSDragging",
|
||||||
|
"NSEvent",
|
||||||
|
"NSGraphics",
|
||||||
|
"NSGraphicsContext",
|
||||||
|
"NSImage",
|
||||||
|
"NSImageRep",
|
||||||
|
"NSMenu",
|
||||||
|
"NSMenuItem",
|
||||||
|
"NSOpenGLView",
|
||||||
|
"NSPasteboard",
|
||||||
|
"NSResponder",
|
||||||
|
"NSRunningApplication",
|
||||||
|
"NSScreen",
|
||||||
|
"NSTextInputClient",
|
||||||
|
"NSTextInputContext",
|
||||||
|
"NSView",
|
||||||
|
"NSWindow",
|
||||||
|
"NSWindowScripting",
|
||||||
|
"NSWindowTabGroup",
|
||||||
|
]
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "ios")'.dependencies.objc2-foundation]
|
||||||
|
version = "0.2.0"
|
||||||
features = [
|
features = [
|
||||||
"dispatch",
|
"dispatch",
|
||||||
"Foundation",
|
"NSArray",
|
||||||
"Foundation_NSArray",
|
"NSEnumerator",
|
||||||
"Foundation_NSString",
|
"NSGeometry",
|
||||||
"Foundation_NSProcessInfo",
|
"NSObjCRuntime",
|
||||||
"Foundation_NSThread",
|
"NSString",
|
||||||
"Foundation_NSSet",
|
"NSProcessInfo",
|
||||||
|
"NSThread",
|
||||||
|
"NSSet",
|
||||||
]
|
]
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ impl MonitorHandleExtIOS for MonitorHandle {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ui_screen(&self) -> *mut c_void {
|
fn ui_screen(&self) -> *mut c_void {
|
||||||
// SAFETY: The marker is only used to get the pointer of the screen
|
// SAFETY: The marker is only used to get the pointer of the screen
|
||||||
let mtm = unsafe { icrate::Foundation::MainThreadMarker::new_unchecked() };
|
let mtm = unsafe { objc2_foundation::MainThreadMarker::new_unchecked() };
|
||||||
objc2::rc::Id::as_ptr(self.inner.ui_screen(mtm)) as *mut c_void
|
objc2::rc::Id::as_ptr(self.inner.ui_screen(mtm)) as *mut c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,7 @@ impl MonitorHandleExtMacOS for MonitorHandle {
|
||||||
|
|
||||||
fn ns_screen(&self) -> Option<*mut c_void> {
|
fn ns_screen(&self) -> Option<*mut c_void> {
|
||||||
// SAFETY: We only use the marker to get a pointer
|
// SAFETY: We only use the marker to get a pointer
|
||||||
let mtm = unsafe { icrate::Foundation::MainThreadMarker::new_unchecked() };
|
let mtm = unsafe { objc2_foundation::MainThreadMarker::new_unchecked() };
|
||||||
self.inner
|
self.inner
|
||||||
.ns_screen(mtm)
|
.ns_screen(mtm)
|
||||||
.map(|s| objc2::rc::Id::as_ptr(&s) as _)
|
.map(|s| objc2::rc::Id::as_ptr(&s) as _)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use icrate::Foundation::{MainThreadMarker, NSObject, NSObjectProtocol};
|
|
||||||
use objc2::{declare_class, mutability, ClassType, DeclaredClass};
|
use objc2::{declare_class, mutability, ClassType, DeclaredClass};
|
||||||
|
use objc2_foundation::{MainThreadMarker, NSObject, NSObjectProtocol};
|
||||||
|
|
||||||
use super::app_state::{self, EventWrapper};
|
use super::app_state::{self, EventWrapper};
|
||||||
use super::uikit::{UIApplication, UIWindow};
|
use super::uikit::{UIApplication, UIWindow};
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ use core_foundation::runloop::{
|
||||||
kCFRunLoopCommonModes, CFRunLoopAddTimer, CFRunLoopGetMain, CFRunLoopRef, CFRunLoopTimerCreate,
|
kCFRunLoopCommonModes, CFRunLoopAddTimer, CFRunLoopGetMain, CFRunLoopRef, CFRunLoopTimerCreate,
|
||||||
CFRunLoopTimerInvalidate, CFRunLoopTimerRef, CFRunLoopTimerSetNextFireDate,
|
CFRunLoopTimerInvalidate, CFRunLoopTimerRef, CFRunLoopTimerSetNextFireDate,
|
||||||
};
|
};
|
||||||
use icrate::Foundation::{
|
|
||||||
CGRect, CGSize, MainThreadMarker, NSInteger, NSOperatingSystemVersion, NSProcessInfo,
|
|
||||||
};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::runtime::AnyObject;
|
use objc2::runtime::AnyObject;
|
||||||
use objc2::{msg_send, sel};
|
use objc2::{msg_send, sel};
|
||||||
|
use objc2_foundation::{
|
||||||
|
CGRect, CGSize, MainThreadMarker, NSInteger, NSOperatingSystemVersion, NSProcessInfo,
|
||||||
|
};
|
||||||
|
|
||||||
use super::uikit::UIView;
|
use super::uikit::UIView;
|
||||||
use super::window::WinitUIWindow;
|
use super::window::WinitUIWindow;
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ use core_foundation::runloop::{
|
||||||
CFRunLoopObserverCreate, CFRunLoopObserverRef, CFRunLoopSourceContext, CFRunLoopSourceCreate,
|
CFRunLoopObserverCreate, CFRunLoopObserverRef, CFRunLoopSourceContext, CFRunLoopSourceCreate,
|
||||||
CFRunLoopSourceInvalidate, CFRunLoopSourceRef, CFRunLoopSourceSignal, CFRunLoopWakeUp,
|
CFRunLoopSourceInvalidate, CFRunLoopSourceRef, CFRunLoopSourceSignal, CFRunLoopWakeUp,
|
||||||
};
|
};
|
||||||
use icrate::Foundation::{MainThreadMarker, NSString};
|
|
||||||
use objc2::ClassType;
|
use objc2::ClassType;
|
||||||
|
use objc2_foundation::{MainThreadMarker, NSString};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::EventLoopError,
|
error::EventLoopError,
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ use std::{
|
||||||
fmt, hash, ptr,
|
fmt, hash, ptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
use icrate::Foundation::{MainThreadBound, MainThreadMarker, NSInteger};
|
|
||||||
use objc2::mutability::IsRetainable;
|
use objc2::mutability::IsRetainable;
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::Message;
|
use objc2::Message;
|
||||||
|
use objc2_foundation::{run_on_main, MainThreadBound, MainThreadMarker, NSInteger};
|
||||||
|
|
||||||
use super::uikit::{UIScreen, UIScreenMode};
|
use super::uikit::{UIScreen, UIScreenMode};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -23,7 +23,7 @@ struct MainThreadBoundDelegateImpls<T>(MainThreadBound<Id<T>>);
|
||||||
|
|
||||||
impl<T: IsRetainable + Message> Clone for MainThreadBoundDelegateImpls<T> {
|
impl<T: IsRetainable + Message> Clone for MainThreadBoundDelegateImpls<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self(MainThreadMarker::run_on_main(|mtm| {
|
Self(run_on_main(|mtm| {
|
||||||
MainThreadBound::new(Id::clone(self.0.get(mtm)), mtm)
|
MainThreadBound::new(Id::clone(self.0.get(mtm)), mtm)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +100,7 @@ pub struct MonitorHandle {
|
||||||
|
|
||||||
impl Clone for MonitorHandle {
|
impl Clone for MonitorHandle {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
MainThreadMarker::run_on_main(|mtm| Self {
|
run_on_main(|mtm| Self {
|
||||||
ui_screen: MainThreadBound::new(self.ui_screen.get(mtm).clone(), mtm),
|
ui_screen: MainThreadBound::new(self.ui_screen.get(mtm).clone(), mtm),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -155,7 +155,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> Option<String> {
|
pub fn name(&self) -> Option<String> {
|
||||||
MainThreadMarker::run_on_main(|mtm| {
|
run_on_main(|mtm| {
|
||||||
let main = UIScreen::main(mtm);
|
let main = UIScreen::main(mtm);
|
||||||
if *self.ui_screen(mtm) == main {
|
if *self.ui_screen(mtm) == main {
|
||||||
Some("Primary".to_string())
|
Some("Primary".to_string())
|
||||||
|
|
@ -197,7 +197,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn video_modes(&self) -> impl Iterator<Item = VideoModeHandle> {
|
pub fn video_modes(&self) -> impl Iterator<Item = VideoModeHandle> {
|
||||||
MainThreadMarker::run_on_main(|mtm| {
|
run_on_main(|mtm| {
|
||||||
let ui_screen = self.ui_screen(mtm);
|
let ui_screen = self.ui_screen(mtm);
|
||||||
// Use Ord impl of RootVideoModeHandle
|
// Use Ord impl of RootVideoModeHandle
|
||||||
|
|
||||||
|
|
@ -218,7 +218,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn preferred_video_mode(&self) -> VideoModeHandle {
|
pub fn preferred_video_mode(&self) -> VideoModeHandle {
|
||||||
MainThreadMarker::run_on_main(|mtm| {
|
run_on_main(|mtm| {
|
||||||
VideoModeHandle::new(
|
VideoModeHandle::new(
|
||||||
self.ui_screen(mtm).clone(),
|
self.ui_screen(mtm).clone(),
|
||||||
self.ui_screen(mtm).preferredMode().unwrap(),
|
self.ui_screen(mtm).preferredMode().unwrap(),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use icrate::Foundation::{CGRect, MainThreadMarker, NSArray, NSObject};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
||||||
|
use objc2_foundation::{CGRect, MainThreadMarker, NSArray, NSObject};
|
||||||
|
|
||||||
use super::{UIResponder, UIWindow};
|
use super::{UIResponder, UIWindow};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use icrate::Foundation::NSObject;
|
|
||||||
use objc2::{extern_class, mutability, ClassType};
|
use objc2::{extern_class, mutability, ClassType};
|
||||||
|
use objc2_foundation::NSObject;
|
||||||
|
|
||||||
extern_class!(
|
extern_class!(
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use icrate::Foundation::{MainThreadMarker, NSInteger, NSObject};
|
|
||||||
use objc2::encode::{Encode, Encoding};
|
use objc2::encode::{Encode, Encoding};
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
||||||
|
use objc2_foundation::{MainThreadMarker, NSInteger, NSObject};
|
||||||
|
|
||||||
extern_class!(
|
extern_class!(
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use icrate::Foundation::NSObject;
|
|
||||||
use objc2::{extern_class, mutability, ClassType};
|
use objc2::{extern_class, mutability, ClassType};
|
||||||
|
use objc2_foundation::NSObject;
|
||||||
|
|
||||||
extern_class!(
|
extern_class!(
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use icrate::Foundation::NSUInteger;
|
|
||||||
use objc2::encode::{Encode, Encoding};
|
use objc2::encode::{Encode, Encoding};
|
||||||
|
use objc2_foundation::NSUInteger;
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use icrate::Foundation::{CGFloat, NSInteger, NSObject, NSUInteger};
|
|
||||||
use objc2::{
|
use objc2::{
|
||||||
encode::{Encode, Encoding},
|
encode::{Encode, Encoding},
|
||||||
extern_class, extern_methods, mutability, ClassType,
|
extern_class, extern_methods, mutability, ClassType,
|
||||||
};
|
};
|
||||||
|
use objc2_foundation::{CGFloat, NSInteger, NSObject, NSUInteger};
|
||||||
|
|
||||||
// https://developer.apple.com/documentation/uikit/uigesturerecognizer
|
// https://developer.apple.com/documentation/uikit/uigesturerecognizer
|
||||||
extern_class!(
|
extern_class!(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use std::os::raw::{c_char, c_int};
|
use std::os::raw::{c_char, c_int};
|
||||||
|
|
||||||
use icrate::Foundation::NSString;
|
use objc2_foundation::NSString;
|
||||||
|
|
||||||
mod application;
|
mod application;
|
||||||
mod coordinate_space;
|
mod coordinate_space;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use icrate::Foundation::NSObject;
|
|
||||||
use objc2::{extern_class, mutability, ClassType};
|
use objc2::{extern_class, mutability, ClassType};
|
||||||
|
use objc2_foundation::NSObject;
|
||||||
|
|
||||||
extern_class!(
|
extern_class!(
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use icrate::Foundation::{CGFloat, CGRect, MainThreadMarker, NSArray, NSInteger, NSObject};
|
|
||||||
use objc2::encode::{Encode, Encoding};
|
use objc2::encode::{Encode, Encoding};
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
||||||
|
use objc2_foundation::{CGFloat, CGRect, MainThreadMarker, NSArray, NSInteger, NSObject};
|
||||||
|
|
||||||
use super::{UICoordinateSpace, UIScreenMode};
|
use super::{UICoordinateSpace, UIScreenMode};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use icrate::Foundation::{CGSize, NSObject};
|
|
||||||
use objc2::{extern_class, extern_methods, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, mutability, ClassType};
|
||||||
|
use objc2_foundation::{CGSize, NSObject};
|
||||||
|
|
||||||
extern_class!(
|
extern_class!(
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use icrate::Foundation::NSInteger;
|
|
||||||
use objc2::encode::{Encode, Encoding};
|
use objc2::encode::{Encode, Encoding};
|
||||||
|
use objc2_foundation::NSInteger;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use icrate::Foundation::{CGFloat, CGPoint, NSInteger, NSObject};
|
|
||||||
use objc2::encode::{Encode, Encoding};
|
use objc2::encode::{Encode, Encoding};
|
||||||
use objc2::{extern_class, extern_methods, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, mutability, ClassType};
|
||||||
|
use objc2_foundation::{CGFloat, CGPoint, NSInteger, NSObject};
|
||||||
|
|
||||||
use super::UIView;
|
use super::UIView;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use icrate::Foundation::{NSInteger, NSObject};
|
|
||||||
use objc2::encode::{Encode, Encoding};
|
use objc2::encode::{Encode, Encoding};
|
||||||
use objc2::{extern_class, extern_methods, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, mutability, ClassType};
|
||||||
|
use objc2_foundation::{NSInteger, NSObject};
|
||||||
|
|
||||||
extern_class!(
|
extern_class!(
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use icrate::Foundation::{CGFloat, CGRect, NSObject};
|
|
||||||
use objc2::encode::{Encode, Encoding};
|
use objc2::encode::{Encode, Encoding};
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
||||||
|
use objc2_foundation::{CGFloat, CGRect, NSObject};
|
||||||
|
|
||||||
use super::{UICoordinateSpace, UIGestureRecognizer, UIResponder, UIViewController};
|
use super::{UICoordinateSpace, UIGestureRecognizer, UIResponder, UIViewController};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use icrate::Foundation::{NSObject, NSUInteger};
|
|
||||||
use objc2::encode::{Encode, Encoding};
|
use objc2::encode::{Encode, Encoding};
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
||||||
|
use objc2_foundation::{NSObject, NSUInteger};
|
||||||
|
|
||||||
use super::{UIResponder, UIView};
|
use super::{UIResponder, UIView};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use icrate::Foundation::NSObject;
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
||||||
|
use objc2_foundation::NSObject;
|
||||||
|
|
||||||
use super::{UIResponder, UIScreen, UIView};
|
use super::{UIResponder, UIScreen, UIView};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
#![allow(clippy::unnecessary_cast)]
|
#![allow(clippy::unnecessary_cast)]
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use icrate::Foundation::{CGFloat, CGRect, MainThreadMarker, NSObject, NSSet};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::runtime::AnyClass;
|
use objc2::runtime::AnyClass;
|
||||||
use objc2::{
|
use objc2::{
|
||||||
declare_class, extern_methods, msg_send, msg_send_id, mutability, sel, ClassType, DeclaredClass,
|
declare_class, extern_methods, msg_send, msg_send_id, mutability, sel, ClassType, DeclaredClass,
|
||||||
};
|
};
|
||||||
|
use objc2_foundation::{CGFloat, CGRect, MainThreadMarker, NSObject, NSSet};
|
||||||
|
|
||||||
use super::app_state::{self, EventWrapper};
|
use super::app_state::{self, EventWrapper};
|
||||||
use super::uikit::{
|
use super::uikit::{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
use icrate::Foundation::{MainThreadMarker, NSObject};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::{declare_class, msg_send_id, mutability, ClassType, DeclaredClass};
|
use objc2::{declare_class, msg_send_id, mutability, ClassType, DeclaredClass};
|
||||||
|
use objc2_foundation::{MainThreadMarker, NSObject};
|
||||||
|
|
||||||
use super::app_state::{self};
|
use super::app_state::{self};
|
||||||
use super::uikit::{
|
use super::uikit::{
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
use icrate::Foundation::{CGFloat, CGPoint, CGRect, CGSize, MainThreadBound, MainThreadMarker};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::runtime::{AnyObject, NSObject};
|
use objc2::runtime::{AnyObject, NSObject};
|
||||||
use objc2::{class, declare_class, msg_send, msg_send_id, mutability, ClassType, DeclaredClass};
|
use objc2::{class, declare_class, msg_send, msg_send_id, mutability, ClassType, DeclaredClass};
|
||||||
|
use objc2_foundation::{CGFloat, CGPoint, CGRect, CGSize, MainThreadBound, MainThreadMarker};
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
use super::app_state::EventWrapper;
|
use super::app_state::EventWrapper;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,8 @@
|
||||||
#![allow(clippy::unnecessary_cast)]
|
#![allow(clippy::unnecessary_cast)]
|
||||||
|
|
||||||
use icrate::AppKit::{
|
|
||||||
NSApplication, NSEvent, NSEventModifierFlagCommand, NSEventTypeKeyUp, NSEventTypeLeftMouseDown,
|
|
||||||
NSEventTypeLeftMouseDragged, NSEventTypeLeftMouseUp, NSEventTypeMouseMoved,
|
|
||||||
NSEventTypeOtherMouseDown, NSEventTypeOtherMouseDragged, NSEventTypeOtherMouseUp,
|
|
||||||
NSEventTypeRightMouseDown, NSEventTypeRightMouseDragged, NSEventTypeRightMouseUp, NSResponder,
|
|
||||||
};
|
|
||||||
use icrate::Foundation::{MainThreadMarker, NSObject};
|
|
||||||
use objc2::{declare_class, msg_send, mutability, ClassType, DeclaredClass};
|
use objc2::{declare_class, msg_send, mutability, ClassType, DeclaredClass};
|
||||||
|
use objc2_app_kit::{NSApplication, NSEvent, NSEventModifierFlags, NSEventType, NSResponder};
|
||||||
|
use objc2_foundation::{MainThreadMarker, NSObject};
|
||||||
|
|
||||||
use super::app_delegate::ApplicationDelegate;
|
use super::app_delegate::ApplicationDelegate;
|
||||||
use super::event::flags_contains;
|
use super::event::flags_contains;
|
||||||
|
|
@ -36,8 +31,8 @@ declare_class!(
|
||||||
// but that doesn't really matter here.
|
// but that doesn't really matter here.
|
||||||
let event_type = unsafe { event.r#type() };
|
let event_type = unsafe { event.r#type() };
|
||||||
let modifier_flags = unsafe { event.modifierFlags() };
|
let modifier_flags = unsafe { event.modifierFlags() };
|
||||||
if event_type == NSEventTypeKeyUp
|
if event_type == NSEventType::KeyUp
|
||||||
&& flags_contains(modifier_flags, NSEventModifierFlagCommand)
|
&& flags_contains(modifier_flags, NSEventModifierFlags::NSEventModifierFlagCommand)
|
||||||
{
|
{
|
||||||
if let Some(key_window) = self.keyWindow() {
|
if let Some(key_window) = self.keyWindow() {
|
||||||
key_window.sendEvent(event);
|
key_window.sendEvent(event);
|
||||||
|
|
@ -55,10 +50,10 @@ fn maybe_dispatch_device_event(delegate: &ApplicationDelegate, event: &NSEvent)
|
||||||
let event_type = unsafe { event.r#type() };
|
let event_type = unsafe { event.r#type() };
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
match event_type {
|
match event_type {
|
||||||
NSEventTypeMouseMoved
|
NSEventType::MouseMoved
|
||||||
| NSEventTypeLeftMouseDragged
|
| NSEventType::LeftMouseDragged
|
||||||
| NSEventTypeOtherMouseDragged
|
| NSEventType::OtherMouseDragged
|
||||||
| NSEventTypeRightMouseDragged => {
|
| NSEventType::RightMouseDragged => {
|
||||||
let delta_x = unsafe { event.deltaX() } as f64;
|
let delta_x = unsafe { event.deltaX() } as f64;
|
||||||
let delta_y = unsafe { event.deltaY() } as f64;
|
let delta_y = unsafe { event.deltaY() } as f64;
|
||||||
|
|
||||||
|
|
@ -82,13 +77,13 @@ fn maybe_dispatch_device_event(delegate: &ApplicationDelegate, event: &NSEvent)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NSEventTypeLeftMouseDown | NSEventTypeRightMouseDown | NSEventTypeOtherMouseDown => {
|
NSEventType::LeftMouseDown | NSEventType::RightMouseDown | NSEventType::OtherMouseDown => {
|
||||||
delegate.queue_device_event(DeviceEvent::Button {
|
delegate.queue_device_event(DeviceEvent::Button {
|
||||||
button: unsafe { event.buttonNumber() } as u32,
|
button: unsafe { event.buttonNumber() } as u32,
|
||||||
state: ElementState::Pressed,
|
state: ElementState::Pressed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
NSEventTypeLeftMouseUp | NSEventTypeRightMouseUp | NSEventTypeOtherMouseUp => {
|
NSEventType::LeftMouseUp | NSEventType::RightMouseUp | NSEventType::OtherMouseUp => {
|
||||||
delegate.queue_device_event(DeviceEvent::Button {
|
delegate.queue_device_event(DeviceEvent::Button {
|
||||||
button: unsafe { event.buttonNumber() } as u32,
|
button: unsafe { event.buttonNumber() } as u32,
|
||||||
state: ElementState::Released,
|
state: ElementState::Released,
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ use std::rc::Weak;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use icrate::AppKit::{NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate};
|
|
||||||
use icrate::Foundation::{MainThreadMarker, NSObject, NSObjectProtocol, NSSize};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::runtime::AnyObject;
|
use objc2::runtime::AnyObject;
|
||||||
use objc2::{declare_class, msg_send_id, mutability, ClassType, DeclaredClass};
|
use objc2::{declare_class, msg_send_id, mutability, ClassType, DeclaredClass};
|
||||||
|
use objc2_app_kit::{NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate};
|
||||||
|
use objc2_foundation::{MainThreadMarker, NSObject, NSObjectProtocol, NSSize};
|
||||||
|
|
||||||
use super::event_handler::EventHandler;
|
use super::event_handler::EventHandler;
|
||||||
use super::event_loop::{stop_app_immediately, ActiveEventLoop, PanicInfo};
|
use super::event_loop::{stop_app_immediately, ActiveEventLoop, PanicInfo};
|
||||||
|
|
@ -21,9 +21,18 @@ use crate::event::{DeviceEvent, Event, InnerSizeWriter, StartCause, WindowEvent}
|
||||||
use crate::event_loop::{ActiveEventLoop as RootActiveEventLoop, ControlFlow};
|
use crate::event_loop::{ActiveEventLoop as RootActiveEventLoop, ControlFlow};
|
||||||
use crate::window::WindowId as RootWindowId;
|
use crate::window::WindowId as RootWindowId;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Policy(NSApplicationActivationPolicy);
|
||||||
|
|
||||||
|
impl Default for Policy {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(NSApplicationActivationPolicy::Regular)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub(super) struct State {
|
pub(super) struct State {
|
||||||
activation_policy: NSApplicationActivationPolicy,
|
activation_policy: Policy,
|
||||||
default_menu: bool,
|
default_menu: bool,
|
||||||
activate_ignoring_other_apps: bool,
|
activate_ignoring_other_apps: bool,
|
||||||
event_handler: EventHandler,
|
event_handler: EventHandler,
|
||||||
|
|
@ -74,7 +83,7 @@ declare_class!(
|
||||||
// We need to delay setting the activation policy and activating the app
|
// We need to delay setting the activation policy and activating the app
|
||||||
// until `applicationDidFinishLaunching` has been called. Otherwise the
|
// until `applicationDidFinishLaunching` has been called. Otherwise the
|
||||||
// menu bar is initially unresponsive on macOS 10.15.
|
// menu bar is initially unresponsive on macOS 10.15.
|
||||||
app.setActivationPolicy(self.ivars().activation_policy);
|
app.setActivationPolicy(self.ivars().activation_policy.0);
|
||||||
|
|
||||||
window_activation_hack(&app);
|
window_activation_hack(&app);
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
|
|
@ -124,7 +133,7 @@ impl ApplicationDelegate {
|
||||||
activate_ignoring_other_apps: bool,
|
activate_ignoring_other_apps: bool,
|
||||||
) -> Id<Self> {
|
) -> Id<Self> {
|
||||||
let this = mtm.alloc().set_ivars(State {
|
let this = mtm.alloc().set_ivars(State {
|
||||||
activation_policy,
|
activation_policy: Policy(activation_policy),
|
||||||
default_menu,
|
default_menu,
|
||||||
activate_ignoring_other_apps,
|
activate_ignoring_other_apps,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@ use std::ffi::c_uchar;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
use icrate::AppKit::{NSBitmapImageRep, NSCursor, NSDeviceRGBColorSpace, NSImage};
|
|
||||||
use icrate::Foundation::{
|
|
||||||
ns_string, NSData, NSDictionary, NSNumber, NSObject, NSObjectProtocol, NSPoint, NSSize,
|
|
||||||
NSString,
|
|
||||||
};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::runtime::Sel;
|
use objc2::runtime::Sel;
|
||||||
use objc2::{msg_send_id, sel, ClassType};
|
use objc2::{msg_send_id, sel, ClassType};
|
||||||
|
use objc2_app_kit::{NSBitmapImageRep, NSCursor, NSDeviceRGBColorSpace, NSImage};
|
||||||
|
use objc2_foundation::{
|
||||||
|
ns_string, NSData, NSDictionary, NSNumber, NSObject, NSObjectProtocol, NSPoint, NSSize,
|
||||||
|
NSString,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::cursor::CursorImage;
|
use crate::cursor::CursorImage;
|
||||||
use crate::cursor::OnlyCursorImageSource;
|
use crate::cursor::OnlyCursorImageSource;
|
||||||
|
|
@ -19,7 +19,7 @@ use crate::window::CursorIcon;
|
||||||
pub struct CustomCursor(pub(crate) Id<NSCursor>);
|
pub struct CustomCursor(pub(crate) Id<NSCursor>);
|
||||||
|
|
||||||
// SAFETY: NSCursor is immutable and thread-safe
|
// SAFETY: NSCursor is immutable and thread-safe
|
||||||
// TODO(madsmtm): Put this logic in icrate itself
|
// TODO(madsmtm): Put this logic in objc2-app-kit itself
|
||||||
unsafe impl Send for CustomCursor {}
|
unsafe impl Send for CustomCursor {}
|
||||||
unsafe impl Sync for CustomCursor {}
|
unsafe impl Sync for CustomCursor {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,9 @@ use core_foundation::{
|
||||||
base::CFRelease,
|
base::CFRelease,
|
||||||
data::{CFDataGetBytePtr, CFDataRef},
|
data::{CFDataGetBytePtr, CFDataRef},
|
||||||
};
|
};
|
||||||
use icrate::AppKit::{
|
|
||||||
NSEvent, NSEventModifierFlagCommand, NSEventModifierFlagControl, NSEventModifierFlagOption,
|
|
||||||
NSEventModifierFlagShift, NSEventModifierFlags, NSEventSubtypeWindowExposed,
|
|
||||||
NSEventTypeApplicationDefined,
|
|
||||||
};
|
|
||||||
use icrate::Foundation::{MainThreadMarker, NSPoint};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
|
use objc2_app_kit::{NSEvent, NSEventModifierFlags, NSEventSubtype, NSEventType};
|
||||||
|
use objc2_foundation::{run_on_main, NSPoint};
|
||||||
use smol_str::SmolStr;
|
use smol_str::SmolStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -48,7 +44,7 @@ pub fn get_modifierless_char(scancode: u16) -> Key {
|
||||||
}
|
}
|
||||||
layout = CFDataGetBytePtr(layout_data as CFDataRef) as *const ffi::UCKeyboardLayout;
|
layout = CFDataGetBytePtr(layout_data as CFDataRef) as *const ffi::UCKeyboardLayout;
|
||||||
}
|
}
|
||||||
let keyboard_type = MainThreadMarker::run_on_main(|_mtm| unsafe { ffi::LMGetKbdType() });
|
let keyboard_type = run_on_main(|_mtm| unsafe { ffi::LMGetKbdType() });
|
||||||
|
|
||||||
let mut result_len = 0;
|
let mut result_len = 0;
|
||||||
let mut dead_keys = 0;
|
let mut dead_keys = 0;
|
||||||
|
|
@ -145,8 +141,8 @@ pub(crate) fn create_key_event(
|
||||||
let key_without_modifiers = get_modifierless_char(scancode);
|
let key_without_modifiers = get_modifierless_char(scancode);
|
||||||
|
|
||||||
let modifiers = unsafe { ns_event.modifierFlags() };
|
let modifiers = unsafe { ns_event.modifierFlags() };
|
||||||
let has_ctrl = flags_contains(modifiers, NSEventModifierFlagControl);
|
let has_ctrl = flags_contains(modifiers, NSEventModifierFlags::NSEventModifierFlagControl);
|
||||||
let has_cmd = flags_contains(modifiers, NSEventModifierFlagCommand);
|
let has_cmd = flags_contains(modifiers, NSEventModifierFlags::NSEventModifierFlagCommand);
|
||||||
|
|
||||||
let logical_key = match text_with_all_modifiers.as_ref() {
|
let logical_key = match text_with_all_modifiers.as_ref() {
|
||||||
// Only checking for ctrl and cmd here, not checking for alt because we DO want to
|
// Only checking for ctrl and cmd here, not checking for alt because we DO want to
|
||||||
|
|
@ -315,17 +311,17 @@ pub fn extra_function_key_to_code(scancode: u16, string: &str) -> PhysicalKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The values are from the https://github.com/apple-oss-distributions/IOHIDFamily/blob/19666c840a6d896468416ff0007040a10b7b46b8/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h#L258-L259
|
// The values are from the https://github.com/apple-oss-distributions/IOHIDFamily/blob/19666c840a6d896468416ff0007040a10b7b46b8/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h#L258-L259
|
||||||
const NX_DEVICELCTLKEYMASK: NSEventModifierFlags = 0x00000001;
|
const NX_DEVICELCTLKEYMASK: NSEventModifierFlags = NSEventModifierFlags(0x00000001);
|
||||||
const NX_DEVICELSHIFTKEYMASK: NSEventModifierFlags = 0x00000002;
|
const NX_DEVICELSHIFTKEYMASK: NSEventModifierFlags = NSEventModifierFlags(0x00000002);
|
||||||
const NX_DEVICERSHIFTKEYMASK: NSEventModifierFlags = 0x00000004;
|
const NX_DEVICERSHIFTKEYMASK: NSEventModifierFlags = NSEventModifierFlags(0x00000004);
|
||||||
const NX_DEVICELCMDKEYMASK: NSEventModifierFlags = 0x00000008;
|
const NX_DEVICELCMDKEYMASK: NSEventModifierFlags = NSEventModifierFlags(0x00000008);
|
||||||
const NX_DEVICERCMDKEYMASK: NSEventModifierFlags = 0x00000010;
|
const NX_DEVICERCMDKEYMASK: NSEventModifierFlags = NSEventModifierFlags(0x00000010);
|
||||||
const NX_DEVICELALTKEYMASK: NSEventModifierFlags = 0x00000020;
|
const NX_DEVICELALTKEYMASK: NSEventModifierFlags = NSEventModifierFlags(0x00000020);
|
||||||
const NX_DEVICERALTKEYMASK: NSEventModifierFlags = 0x00000040;
|
const NX_DEVICERALTKEYMASK: NSEventModifierFlags = NSEventModifierFlags(0x00000040);
|
||||||
const NX_DEVICERCTLKEYMASK: NSEventModifierFlags = 0x00002000;
|
const NX_DEVICERCTLKEYMASK: NSEventModifierFlags = NSEventModifierFlags(0x00002000);
|
||||||
|
|
||||||
pub(super) fn flags_contains(flags: NSEventModifierFlags, value: NSEventModifierFlags) -> bool {
|
pub(super) fn flags_contains(flags: NSEventModifierFlags, value: NSEventModifierFlags) -> bool {
|
||||||
flags & value == value
|
flags.0 & value.0 == value.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn lalt_pressed(event: &NSEvent) -> bool {
|
pub(super) fn lalt_pressed(event: &NSEvent) -> bool {
|
||||||
|
|
@ -343,7 +339,7 @@ pub(super) fn event_mods(event: &NSEvent) -> Modifiers {
|
||||||
|
|
||||||
state.set(
|
state.set(
|
||||||
ModifiersState::SHIFT,
|
ModifiersState::SHIFT,
|
||||||
flags_contains(flags, NSEventModifierFlagShift),
|
flags_contains(flags, NSEventModifierFlags::NSEventModifierFlagShift),
|
||||||
);
|
);
|
||||||
pressed_mods.set(
|
pressed_mods.set(
|
||||||
ModifiersKeys::LSHIFT,
|
ModifiersKeys::LSHIFT,
|
||||||
|
|
@ -356,7 +352,7 @@ pub(super) fn event_mods(event: &NSEvent) -> Modifiers {
|
||||||
|
|
||||||
state.set(
|
state.set(
|
||||||
ModifiersState::CONTROL,
|
ModifiersState::CONTROL,
|
||||||
flags_contains(flags, NSEventModifierFlagControl),
|
flags_contains(flags, NSEventModifierFlags::NSEventModifierFlagControl),
|
||||||
);
|
);
|
||||||
pressed_mods.set(
|
pressed_mods.set(
|
||||||
ModifiersKeys::LCONTROL,
|
ModifiersKeys::LCONTROL,
|
||||||
|
|
@ -369,7 +365,7 @@ pub(super) fn event_mods(event: &NSEvent) -> Modifiers {
|
||||||
|
|
||||||
state.set(
|
state.set(
|
||||||
ModifiersState::ALT,
|
ModifiersState::ALT,
|
||||||
flags_contains(flags, NSEventModifierFlagOption),
|
flags_contains(flags, NSEventModifierFlags::NSEventModifierFlagOption),
|
||||||
);
|
);
|
||||||
pressed_mods.set(
|
pressed_mods.set(
|
||||||
ModifiersKeys::LALT,
|
ModifiersKeys::LALT,
|
||||||
|
|
@ -382,7 +378,7 @@ pub(super) fn event_mods(event: &NSEvent) -> Modifiers {
|
||||||
|
|
||||||
state.set(
|
state.set(
|
||||||
ModifiersState::SUPER,
|
ModifiersState::SUPER,
|
||||||
flags_contains(flags, NSEventModifierFlagCommand),
|
flags_contains(flags, NSEventModifierFlags::NSEventModifierFlagCommand),
|
||||||
);
|
);
|
||||||
pressed_mods.set(
|
pressed_mods.set(
|
||||||
ModifiersKeys::LSUPER,
|
ModifiersKeys::LSUPER,
|
||||||
|
|
@ -402,13 +398,13 @@ pub(super) fn event_mods(event: &NSEvent) -> Modifiers {
|
||||||
pub(super) fn dummy_event() -> Option<Id<NSEvent>> {
|
pub(super) fn dummy_event() -> Option<Id<NSEvent>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2(
|
NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2(
|
||||||
NSEventTypeApplicationDefined,
|
NSEventType::ApplicationDefined,
|
||||||
NSPoint::new(0.0, 0.0),
|
NSPoint::new(0.0, 0.0),
|
||||||
0, // Empty NSEventModifierFlags
|
NSEventModifierFlags(0),
|
||||||
0.0,
|
0.0,
|
||||||
0,
|
0,
|
||||||
None,
|
None,
|
||||||
NSEventSubtypeWindowExposed,
|
NSEventSubtype::WindowExposed.0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,13 @@ use core_foundation::runloop::{
|
||||||
kCFRunLoopCommonModes, CFRunLoopAddSource, CFRunLoopGetMain, CFRunLoopSourceContext,
|
kCFRunLoopCommonModes, CFRunLoopAddSource, CFRunLoopGetMain, CFRunLoopSourceContext,
|
||||||
CFRunLoopSourceCreate, CFRunLoopSourceRef, CFRunLoopSourceSignal, CFRunLoopWakeUp,
|
CFRunLoopSourceCreate, CFRunLoopSourceRef, CFRunLoopSourceSignal, CFRunLoopWakeUp,
|
||||||
};
|
};
|
||||||
use icrate::AppKit::{
|
|
||||||
NSApplication, NSApplicationActivationPolicyAccessory, NSApplicationActivationPolicyProhibited,
|
|
||||||
NSApplicationActivationPolicyRegular, NSWindow,
|
|
||||||
};
|
|
||||||
use icrate::Foundation::{MainThreadMarker, NSObjectProtocol};
|
|
||||||
use objc2::{msg_send_id, ClassType};
|
use objc2::{msg_send_id, ClassType};
|
||||||
use objc2::{
|
use objc2::{
|
||||||
rc::{autoreleasepool, Id},
|
rc::{autoreleasepool, Id},
|
||||||
runtime::ProtocolObject,
|
runtime::ProtocolObject,
|
||||||
};
|
};
|
||||||
|
use objc2_app_kit::{NSApplication, NSApplicationActivationPolicy, NSWindow};
|
||||||
|
use objc2_foundation::{MainThreadMarker, NSObjectProtocol};
|
||||||
|
|
||||||
use super::event::dummy_event;
|
use super::event::dummy_event;
|
||||||
use super::{
|
use super::{
|
||||||
|
|
@ -232,9 +229,9 @@ impl<T> EventLoop<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let activation_policy = match attributes.activation_policy {
|
let activation_policy = match attributes.activation_policy {
|
||||||
ActivationPolicy::Regular => NSApplicationActivationPolicyRegular,
|
ActivationPolicy::Regular => NSApplicationActivationPolicy::Regular,
|
||||||
ActivationPolicy::Accessory => NSApplicationActivationPolicyAccessory,
|
ActivationPolicy::Accessory => NSApplicationActivationPolicy::Accessory,
|
||||||
ActivationPolicy::Prohibited => NSApplicationActivationPolicyProhibited,
|
ActivationPolicy::Prohibited => NSApplicationActivationPolicy::Prohibited,
|
||||||
};
|
};
|
||||||
let delegate = ApplicationDelegate::new(
|
let delegate = ApplicationDelegate::new(
|
||||||
mtm,
|
mtm,
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
use icrate::AppKit::{
|
|
||||||
NSApplication, NSEventModifierFlagCommand, NSEventModifierFlagOption, NSEventModifierFlags,
|
|
||||||
NSMenu, NSMenuItem,
|
|
||||||
};
|
|
||||||
use icrate::Foundation::{ns_string, MainThreadMarker, NSProcessInfo, NSString};
|
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::runtime::Sel;
|
use objc2::runtime::Sel;
|
||||||
use objc2::sel;
|
use objc2::sel;
|
||||||
|
use objc2_app_kit::{NSApplication, NSEventModifierFlags, NSMenu, NSMenuItem};
|
||||||
|
use objc2_foundation::{ns_string, MainThreadMarker, NSProcessInfo, NSString};
|
||||||
|
|
||||||
struct KeyEquivalent<'a> {
|
struct KeyEquivalent<'a> {
|
||||||
key: &'a NSString,
|
key: &'a NSString,
|
||||||
|
|
@ -58,7 +55,10 @@ pub fn initialize(app: &NSApplication) {
|
||||||
Some(sel!(hideOtherApplications:)),
|
Some(sel!(hideOtherApplications:)),
|
||||||
Some(KeyEquivalent {
|
Some(KeyEquivalent {
|
||||||
key: ns_string!("h"),
|
key: ns_string!("h"),
|
||||||
masks: Some(NSEventModifierFlagOption | NSEventModifierFlagCommand),
|
masks: Some(NSEventModifierFlags(
|
||||||
|
NSEventModifierFlags::NSEventModifierFlagOption.0
|
||||||
|
| NSEventModifierFlags::NSEventModifierFlagCommand.0,
|
||||||
|
)),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ use core_foundation::{
|
||||||
use core_graphics::display::{
|
use core_graphics::display::{
|
||||||
CGDirectDisplayID, CGDisplay, CGDisplayBounds, CGDisplayCopyDisplayMode,
|
CGDirectDisplayID, CGDisplay, CGDisplayBounds, CGDisplayCopyDisplayMode,
|
||||||
};
|
};
|
||||||
use icrate::AppKit::NSScreen;
|
|
||||||
use icrate::Foundation::{ns_string, MainThreadMarker, NSNumber, NSPoint, NSRect};
|
|
||||||
use objc2::{rc::Id, runtime::AnyObject};
|
use objc2::{rc::Id, runtime::AnyObject};
|
||||||
|
use objc2_app_kit::NSScreen;
|
||||||
|
use objc2_foundation::{ns_string, run_on_main, MainThreadMarker, NSNumber, NSPoint, NSRect};
|
||||||
|
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
use crate::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
use crate::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
||||||
|
|
@ -203,7 +203,7 @@ impl MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scale_factor(&self) -> f64 {
|
pub fn scale_factor(&self) -> f64 {
|
||||||
MainThreadMarker::run_on_main(|mtm| {
|
run_on_main(|mtm| {
|
||||||
match self.ns_screen(mtm) {
|
match self.ns_screen(mtm) {
|
||||||
Some(screen) => screen.backingScaleFactor() as f64,
|
Some(screen) => screen.backingScaleFactor() as f64,
|
||||||
None => 1.0, // default to 1.0 when we can't find the screen
|
None => 1.0, // default to 1.0 when we can't find the screen
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use core_foundation::runloop::{
|
||||||
CFRunLoopObserverRef, CFRunLoopRef, CFRunLoopTimerCreate, CFRunLoopTimerInvalidate,
|
CFRunLoopObserverRef, CFRunLoopRef, CFRunLoopTimerCreate, CFRunLoopTimerInvalidate,
|
||||||
CFRunLoopTimerRef, CFRunLoopTimerSetNextFireDate, CFRunLoopWakeUp,
|
CFRunLoopTimerRef, CFRunLoopTimerSetNextFireDate, CFRunLoopWakeUp,
|
||||||
};
|
};
|
||||||
use icrate::Foundation::MainThreadMarker;
|
use objc2_foundation::MainThreadMarker;
|
||||||
|
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
use super::{
|
use super::{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use icrate::Foundation::{NSNotFound, NSRange, NSUInteger};
|
use objc2_foundation::{NSNotFound, NSRange, NSUInteger};
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
pub const EMPTY_RANGE: NSRange = NSRange {
|
pub static EMPTY_RANGE: NSRange = NSRange {
|
||||||
location: NSNotFound as NSUInteger,
|
location: NSNotFound as NSUInteger,
|
||||||
length: 0,
|
length: 0,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,20 @@ use std::cell::{Cell, RefCell};
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use icrate::AppKit::{
|
|
||||||
NSApplication, NSCursor, NSEvent, NSEventPhaseBegan, NSEventPhaseCancelled,
|
|
||||||
NSEventPhaseChanged, NSEventPhaseEnded, NSEventPhaseMayBegin, NSResponder, NSTextInputClient,
|
|
||||||
NSTrackingRectTag, NSView,
|
|
||||||
};
|
|
||||||
use icrate::Foundation::{
|
|
||||||
MainThreadMarker, NSArray, NSAttributedString, NSAttributedStringKey, NSCopying,
|
|
||||||
NSMutableAttributedString, NSObject, NSObjectProtocol, NSPoint, NSRange, NSRect, NSSize,
|
|
||||||
NSString, NSUInteger,
|
|
||||||
};
|
|
||||||
use objc2::rc::{Id, WeakId};
|
use objc2::rc::{Id, WeakId};
|
||||||
use objc2::runtime::{AnyObject, Sel};
|
use objc2::runtime::{AnyObject, Sel};
|
||||||
use objc2::{
|
use objc2::{
|
||||||
class, declare_class, msg_send, msg_send_id, mutability, sel, ClassType, DeclaredClass,
|
class, declare_class, msg_send, msg_send_id, mutability, sel, ClassType, DeclaredClass,
|
||||||
};
|
};
|
||||||
|
use objc2_app_kit::{
|
||||||
|
NSApplication, NSCursor, NSEvent, NSEventPhase, NSResponder, NSTextInputClient,
|
||||||
|
NSTrackingRectTag, NSView,
|
||||||
|
};
|
||||||
|
use objc2_foundation::{
|
||||||
|
MainThreadMarker, NSArray, NSAttributedString, NSAttributedStringKey, NSCopying,
|
||||||
|
NSMutableAttributedString, NSObject, NSObjectProtocol, NSPoint, NSRange, NSRect, NSSize,
|
||||||
|
NSString, NSUInteger,
|
||||||
|
};
|
||||||
|
|
||||||
use super::app_delegate::ApplicationDelegate;
|
use super::app_delegate::ApplicationDelegate;
|
||||||
use super::cursor::{default_cursor, invisible_cursor};
|
use super::cursor::{default_cursor, invisible_cursor};
|
||||||
|
|
@ -175,7 +174,9 @@ declare_class!(
|
||||||
}
|
}
|
||||||
|
|
||||||
let rect = self.frame();
|
let rect = self.frame();
|
||||||
let tracking_rect = unsafe { self.addTrackingRect_owner_userData_assumeInside(rect, self, ptr::null_mut(), false) };
|
let tracking_rect = unsafe {
|
||||||
|
self.addTrackingRect_owner_userData_assumeInside(rect, self, ptr::null_mut(), false)
|
||||||
|
};
|
||||||
assert_ne!(tracking_rect, 0, "failed adding tracking rect");
|
assert_ne!(tracking_rect, 0, "failed adding tracking rect");
|
||||||
self.ivars().tracking_rect.set(Some(tracking_rect));
|
self.ivars().tracking_rect.set(Some(tracking_rect));
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +189,9 @@ declare_class!(
|
||||||
}
|
}
|
||||||
|
|
||||||
let rect = self.frame();
|
let rect = self.frame();
|
||||||
let tracking_rect = unsafe { self.addTrackingRect_owner_userData_assumeInside(rect, self, ptr::null_mut(), false) };
|
let tracking_rect = unsafe {
|
||||||
|
self.addTrackingRect_owner_userData_assumeInside(rect, self, ptr::null_mut(), false)
|
||||||
|
};
|
||||||
assert_ne!(tracking_rect, 0, "failed adding tracking rect");
|
assert_ne!(tracking_rect, 0, "failed adding tracking rect");
|
||||||
self.ivars().tracking_rect.set(Some(tracking_rect));
|
self.ivars().tracking_rect.set(Some(tracking_rect));
|
||||||
|
|
||||||
|
|
@ -371,9 +374,13 @@ declare_class!(
|
||||||
_actual_range: *mut NSRange,
|
_actual_range: *mut NSRange,
|
||||||
) -> NSRect {
|
) -> NSRect {
|
||||||
trace_scope!("firstRectForCharacterRange:actualRange:");
|
trace_scope!("firstRectForCharacterRange:actualRange:");
|
||||||
let rect = dbg!(NSRect::new(self.ivars().ime_position.get(), self.ivars().ime_size.get()));
|
let rect = NSRect::new(
|
||||||
|
self.ivars().ime_position.get(),
|
||||||
|
self.ivars().ime_size.get()
|
||||||
|
);
|
||||||
// Return value is expected to be in screen coordinates, so we need a conversion here
|
// Return value is expected to be in screen coordinates, so we need a conversion here
|
||||||
unsafe { self.window().convertRectToScreen(self.convertRect_toView(rect, None)) }
|
self.window()
|
||||||
|
.convertRectToScreen(self.convertRect_toView(rect, None))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[method(insertText:replacementRange:)]
|
#[method(insertText:replacementRange:)]
|
||||||
|
|
@ -415,7 +422,8 @@ declare_class!(
|
||||||
|
|
||||||
self.ivars().forward_key_to_app.set(true);
|
self.ivars().forward_key_to_app.set(true);
|
||||||
|
|
||||||
if unsafe { self.hasMarkedText() } && self.ivars().ime_state.get() == ImeState::Preedit {
|
if unsafe { self.hasMarkedText() } && self.ivars().ime_state.get() == ImeState::Preedit
|
||||||
|
{
|
||||||
// Leave preedit so that we also report the key-up for this key.
|
// Leave preedit so that we also report the key-up for this key.
|
||||||
self.ivars().ime_state.set(ImeState::Ground);
|
self.ivars().ime_state.set(ImeState::Ground);
|
||||||
}
|
}
|
||||||
|
|
@ -666,19 +674,11 @@ declare_class!(
|
||||||
// report the touch phase.
|
// report the touch phase.
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
let phase = match unsafe { event.momentumPhase() } {
|
let phase = match unsafe { event.momentumPhase() } {
|
||||||
NSEventPhaseMayBegin | NSEventPhaseBegan => {
|
NSEventPhase::MayBegin | NSEventPhase::Began => TouchPhase::Started,
|
||||||
TouchPhase::Started
|
NSEventPhase::Ended | NSEventPhase::Cancelled => TouchPhase::Ended,
|
||||||
}
|
|
||||||
NSEventPhaseEnded | NSEventPhaseCancelled => {
|
|
||||||
TouchPhase::Ended
|
|
||||||
}
|
|
||||||
_ => match unsafe { event.phase() } {
|
_ => match unsafe { event.phase() } {
|
||||||
NSEventPhaseMayBegin | NSEventPhaseBegan => {
|
NSEventPhase::MayBegin | NSEventPhase::Began => TouchPhase::Started,
|
||||||
TouchPhase::Started
|
NSEventPhase::Ended | NSEventPhase::Cancelled => TouchPhase::Ended,
|
||||||
}
|
|
||||||
NSEventPhaseEnded | NSEventPhaseCancelled => {
|
|
||||||
TouchPhase::Ended
|
|
||||||
}
|
|
||||||
_ => TouchPhase::Moved,
|
_ => TouchPhase::Moved,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -701,10 +701,10 @@ declare_class!(
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
let phase = match unsafe { event.phase() } {
|
let phase = match unsafe { event.phase() } {
|
||||||
NSEventPhaseBegan => TouchPhase::Started,
|
NSEventPhase::Began => TouchPhase::Started,
|
||||||
NSEventPhaseChanged => TouchPhase::Moved,
|
NSEventPhase::Changed => TouchPhase::Moved,
|
||||||
NSEventPhaseCancelled => TouchPhase::Cancelled,
|
NSEventPhase::Cancelled => TouchPhase::Cancelled,
|
||||||
NSEventPhaseEnded => TouchPhase::Ended,
|
NSEventPhase::Ended => TouchPhase::Ended,
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -734,10 +734,10 @@ declare_class!(
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
let phase = match unsafe { event.phase() } {
|
let phase = match unsafe { event.phase() } {
|
||||||
NSEventPhaseBegan => TouchPhase::Started,
|
NSEventPhase::Began => TouchPhase::Started,
|
||||||
NSEventPhaseChanged => TouchPhase::Moved,
|
NSEventPhase::Changed => TouchPhase::Moved,
|
||||||
NSEventPhaseCancelled => TouchPhase::Cancelled,
|
NSEventPhase::Cancelled => TouchPhase::Cancelled,
|
||||||
NSEventPhaseEnded => TouchPhase::Ended,
|
NSEventPhase::Ended => TouchPhase::Ended,
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#![allow(clippy::unnecessary_cast)]
|
#![allow(clippy::unnecessary_cast)]
|
||||||
|
|
||||||
use icrate::AppKit::{NSResponder, NSWindow};
|
|
||||||
use icrate::Foundation::{MainThreadBound, MainThreadMarker, NSObject};
|
|
||||||
use objc2::rc::{autoreleasepool, Id};
|
use objc2::rc::{autoreleasepool, Id};
|
||||||
use objc2::{declare_class, mutability, ClassType, DeclaredClass};
|
use objc2::{declare_class, mutability, ClassType, DeclaredClass};
|
||||||
|
use objc2_app_kit::{NSResponder, NSWindow};
|
||||||
|
use objc2_foundation::{MainThreadBound, MainThreadMarker, NSObject};
|
||||||
|
|
||||||
use super::event_loop::ActiveEventLoop;
|
use super::event_loop::ActiveEventLoop;
|
||||||
use super::window_delegate::WindowDelegate;
|
use super::window_delegate::WindowDelegate;
|
||||||
|
|
|
||||||
|
|
@ -4,29 +4,24 @@ use std::collections::VecDeque;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use core_graphics::display::{CGDisplay, CGPoint};
|
use core_graphics::display::{CGDisplay, CGPoint};
|
||||||
use icrate::AppKit::{
|
|
||||||
NSAppKitVersionNumber, NSAppKitVersionNumber10_12, NSAppearance, NSApplication,
|
|
||||||
NSApplicationPresentationAutoHideDock, NSApplicationPresentationAutoHideMenuBar,
|
|
||||||
NSApplicationPresentationFullScreen, NSApplicationPresentationHideDock,
|
|
||||||
NSApplicationPresentationHideMenuBar, NSApplicationPresentationOptions, NSBackingStoreBuffered,
|
|
||||||
NSColor, NSCriticalRequest, NSDraggingDestination, NSFilenamesPboardType,
|
|
||||||
NSInformationalRequest, NSPasteboard, NSScreen, NSView, NSWindowAbove, NSWindowCloseButton,
|
|
||||||
NSWindowDelegate, NSWindowFullScreenButton, NSWindowLevel, NSWindowMiniaturizeButton,
|
|
||||||
NSWindowOcclusionStateVisible, NSWindowSharingNone, NSWindowSharingReadOnly, NSWindowStyleMask,
|
|
||||||
NSWindowStyleMaskBorderless, NSWindowStyleMaskClosable, NSWindowStyleMaskFullSizeContentView,
|
|
||||||
NSWindowStyleMaskMiniaturizable, NSWindowStyleMaskResizable, NSWindowStyleMaskTitled,
|
|
||||||
NSWindowTabbingModePreferred, NSWindowTitleHidden, NSWindowZoomButton,
|
|
||||||
};
|
|
||||||
use icrate::Foundation::{
|
|
||||||
CGFloat, MainThreadMarker, NSArray, NSCopying, NSObject, NSObjectProtocol, NSPoint, NSRect,
|
|
||||||
NSSize, NSString,
|
|
||||||
};
|
|
||||||
use monitor::VideoModeHandle;
|
use monitor::VideoModeHandle;
|
||||||
use objc2::rc::{autoreleasepool, Id};
|
use objc2::rc::{autoreleasepool, Id};
|
||||||
use objc2::runtime::{AnyObject, ProtocolObject};
|
use objc2::runtime::{AnyObject, ProtocolObject};
|
||||||
use objc2::{
|
use objc2::{
|
||||||
class, declare_class, msg_send, msg_send_id, mutability, sel, ClassType, DeclaredClass,
|
class, declare_class, msg_send, msg_send_id, mutability, sel, ClassType, DeclaredClass,
|
||||||
};
|
};
|
||||||
|
use objc2_app_kit::{
|
||||||
|
NSAppKitVersionNumber, NSAppKitVersionNumber10_12, NSAppearance, NSApplication,
|
||||||
|
NSApplicationPresentationOptions, NSBackingStoreType, NSColor, NSDraggingDestination,
|
||||||
|
NSFilenamesPboardType, NSPasteboard, NSRequestUserAttentionType, NSScreen, NSView,
|
||||||
|
NSWindowButton, NSWindowDelegate, NSWindowFullScreenButton, NSWindowLevel,
|
||||||
|
NSWindowOcclusionState, NSWindowOrderingMode, NSWindowSharingType, NSWindowStyleMask,
|
||||||
|
NSWindowTabbingMode, NSWindowTitleVisibility,
|
||||||
|
};
|
||||||
|
use objc2_foundation::{
|
||||||
|
CGFloat, MainThreadMarker, NSArray, NSCopying, NSObject, NSObjectProtocol, NSPoint, NSRect,
|
||||||
|
NSSize, NSString,
|
||||||
|
};
|
||||||
|
|
||||||
use super::app_delegate::ApplicationDelegate;
|
use super::app_delegate::ApplicationDelegate;
|
||||||
use super::cursor::cursor_from_icon;
|
use super::cursor::cursor_from_icon;
|
||||||
|
|
@ -266,9 +261,11 @@ declare_class!(
|
||||||
let mut options = proposed_options;
|
let mut options = proposed_options;
|
||||||
let fullscreen = self.ivars().fullscreen.borrow();
|
let fullscreen = self.ivars().fullscreen.borrow();
|
||||||
if let Some(Fullscreen::Exclusive(_)) = &*fullscreen {
|
if let Some(Fullscreen::Exclusive(_)) = &*fullscreen {
|
||||||
options = NSApplicationPresentationFullScreen
|
options = NSApplicationPresentationOptions(
|
||||||
| NSApplicationPresentationHideDock
|
NSApplicationPresentationOptions::NSApplicationPresentationFullScreen.0
|
||||||
| NSApplicationPresentationHideMenuBar;
|
| NSApplicationPresentationOptions::NSApplicationPresentationHideDock.0
|
||||||
|
| NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar.0,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
options
|
options
|
||||||
|
|
@ -337,8 +334,8 @@ declare_class!(
|
||||||
#[method(windowDidChangeOcclusionState:)]
|
#[method(windowDidChangeOcclusionState:)]
|
||||||
fn window_did_change_occlusion_state(&self, _: Option<&AnyObject>) {
|
fn window_did_change_occlusion_state(&self, _: Option<&AnyObject>) {
|
||||||
trace_scope!("windowDidChangeOcclusionState:");
|
trace_scope!("windowDidChangeOcclusionState:");
|
||||||
let visible = self.window().occlusionState() & NSWindowOcclusionStateVisible
|
let visible = self.window().occlusionState().0 & NSWindowOcclusionState::Visible.0
|
||||||
== NSWindowOcclusionStateVisible;
|
== NSWindowOcclusionState::Visible.0;
|
||||||
self.queue_event(WindowEvent::Occluded(!visible));
|
self.queue_event(WindowEvent::Occluded(!visible));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -490,39 +487,39 @@ fn new_window(attrs: &WindowAttributes, mtm: MainThreadMarker) -> Option<Id<Wini
|
||||||
// if decorations is set to false, ignore pl_attrs
|
// if decorations is set to false, ignore pl_attrs
|
||||||
//
|
//
|
||||||
// if the titlebar is hidden, ignore other pl_attrs
|
// if the titlebar is hidden, ignore other pl_attrs
|
||||||
NSWindowStyleMaskBorderless
|
NSWindowStyleMask::Borderless.0
|
||||||
| NSWindowStyleMaskResizable
|
| NSWindowStyleMask::Resizable.0
|
||||||
| NSWindowStyleMaskMiniaturizable
|
| NSWindowStyleMask::Miniaturizable.0
|
||||||
} else {
|
} else {
|
||||||
// default case, resizable window with titlebar and titlebar buttons
|
// default case, resizable window with titlebar and titlebar buttons
|
||||||
NSWindowStyleMaskClosable
|
NSWindowStyleMask::Closable.0
|
||||||
| NSWindowStyleMaskMiniaturizable
|
| NSWindowStyleMask::Miniaturizable.0
|
||||||
| NSWindowStyleMaskResizable
|
| NSWindowStyleMask::Resizable.0
|
||||||
| NSWindowStyleMaskTitled
|
| NSWindowStyleMask::Titled.0
|
||||||
};
|
};
|
||||||
|
|
||||||
if !attrs.resizable {
|
if !attrs.resizable {
|
||||||
masks &= !NSWindowStyleMaskResizable;
|
masks &= !NSWindowStyleMask::Resizable.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !attrs.enabled_buttons.contains(WindowButtons::MINIMIZE) {
|
if !attrs.enabled_buttons.contains(WindowButtons::MINIMIZE) {
|
||||||
masks &= !NSWindowStyleMaskMiniaturizable;
|
masks &= !NSWindowStyleMask::Miniaturizable.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !attrs.enabled_buttons.contains(WindowButtons::CLOSE) {
|
if !attrs.enabled_buttons.contains(WindowButtons::CLOSE) {
|
||||||
masks &= !NSWindowStyleMaskClosable;
|
masks &= !NSWindowStyleMask::Closable.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if attrs.platform_specific.fullsize_content_view {
|
if attrs.platform_specific.fullsize_content_view {
|
||||||
masks |= NSWindowStyleMaskFullSizeContentView;
|
masks |= NSWindowStyleMask::FullSizeContentView.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let window: Option<Id<WinitWindow>> = unsafe {
|
let window: Option<Id<WinitWindow>> = unsafe {
|
||||||
msg_send_id![
|
msg_send_id![
|
||||||
super(mtm.alloc().set_ivars(())),
|
super(mtm.alloc().set_ivars(())),
|
||||||
initWithContentRect: frame,
|
initWithContentRect: frame,
|
||||||
styleMask: masks,
|
styleMask: NSWindowStyleMask(masks),
|
||||||
backing: NSBackingStoreBuffered,
|
backing: NSBackingStoreType::NSBackingStoreBuffered,
|
||||||
defer: false,
|
defer: false,
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -538,26 +535,26 @@ fn new_window(attrs: &WindowAttributes, mtm: MainThreadMarker) -> Option<Id<Wini
|
||||||
|
|
||||||
if let Some(identifier) = &attrs.platform_specific.tabbing_identifier {
|
if let Some(identifier) = &attrs.platform_specific.tabbing_identifier {
|
||||||
window.setTabbingIdentifier(&NSString::from_str(identifier));
|
window.setTabbingIdentifier(&NSString::from_str(identifier));
|
||||||
window.setTabbingMode(NSWindowTabbingModePreferred);
|
window.setTabbingMode(NSWindowTabbingMode::Preferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
if attrs.content_protected {
|
if attrs.content_protected {
|
||||||
window.setSharingType(NSWindowSharingNone);
|
window.setSharingType(NSWindowSharingType::NSWindowSharingNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if attrs.platform_specific.titlebar_transparent {
|
if attrs.platform_specific.titlebar_transparent {
|
||||||
window.setTitlebarAppearsTransparent(true);
|
window.setTitlebarAppearsTransparent(true);
|
||||||
}
|
}
|
||||||
if attrs.platform_specific.title_hidden {
|
if attrs.platform_specific.title_hidden {
|
||||||
window.setTitleVisibility(NSWindowTitleHidden);
|
window.setTitleVisibility(NSWindowTitleVisibility::NSWindowTitleHidden);
|
||||||
}
|
}
|
||||||
if attrs.platform_specific.titlebar_buttons_hidden {
|
if attrs.platform_specific.titlebar_buttons_hidden {
|
||||||
for titlebar_button in &[
|
for titlebar_button in &[
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
NSWindowFullScreenButton,
|
NSWindowFullScreenButton,
|
||||||
NSWindowMiniaturizeButton,
|
NSWindowButton::NSWindowMiniaturizeButton,
|
||||||
NSWindowCloseButton,
|
NSWindowButton::NSWindowCloseButton,
|
||||||
NSWindowZoomButton,
|
NSWindowButton::NSWindowZoomButton,
|
||||||
] {
|
] {
|
||||||
if let Some(button) = window.standardWindowButton(*titlebar_button) {
|
if let Some(button) = window.standardWindowButton(*titlebar_button) {
|
||||||
button.setHidden(true);
|
button.setHidden(true);
|
||||||
|
|
@ -569,7 +566,7 @@ fn new_window(attrs: &WindowAttributes, mtm: MainThreadMarker) -> Option<Id<Wini
|
||||||
}
|
}
|
||||||
|
|
||||||
if !attrs.enabled_buttons.contains(WindowButtons::MAXIMIZE) {
|
if !attrs.enabled_buttons.contains(WindowButtons::MAXIMIZE) {
|
||||||
if let Some(button) = window.standardWindowButton(NSWindowZoomButton) {
|
if let Some(button) = window.standardWindowButton(NSWindowButton::NSWindowZoomButton) {
|
||||||
button.setEnabled(false);
|
button.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -641,7 +638,9 @@ impl WindowDelegate {
|
||||||
|
|
||||||
// SAFETY: We know that there are no parent -> child -> parent cycles since the only place in `winit`
|
// SAFETY: We know that there are no parent -> child -> parent cycles since the only place in `winit`
|
||||||
// where we allow making a window a child window is right here, just after it's been created.
|
// where we allow making a window a child window is right here, just after it's been created.
|
||||||
unsafe { parent.addChildWindow_ordered(&window, NSWindowAbove) };
|
unsafe {
|
||||||
|
parent.addChildWindow_ordered(&window, NSWindowOrderingMode::NSWindowAbove)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
Some(raw) => panic!("invalid raw window handle {raw:?} on macOS"),
|
Some(raw) => panic!("invalid raw window handle {raw:?} on macOS"),
|
||||||
None => (),
|
None => (),
|
||||||
|
|
@ -975,13 +974,13 @@ impl WindowDelegate {
|
||||||
self.ivars().resizable.set(resizable);
|
self.ivars().resizable.set(resizable);
|
||||||
let fullscreen = self.ivars().fullscreen.borrow().is_some();
|
let fullscreen = self.ivars().fullscreen.borrow().is_some();
|
||||||
if !fullscreen {
|
if !fullscreen {
|
||||||
let mut mask = self.window().styleMask();
|
let mut mask = self.window().styleMask().0;
|
||||||
if resizable {
|
if resizable {
|
||||||
mask |= NSWindowStyleMaskResizable;
|
mask |= NSWindowStyleMask::Resizable.0;
|
||||||
} else {
|
} else {
|
||||||
mask &= !NSWindowStyleMaskResizable;
|
mask &= !NSWindowStyleMask::Resizable.0;
|
||||||
}
|
}
|
||||||
self.set_style_mask(mask);
|
self.set_style_mask(NSWindowStyleMask(mask));
|
||||||
}
|
}
|
||||||
// Otherwise, we don't change the mask until we exit fullscreen.
|
// Otherwise, we don't change the mask until we exit fullscreen.
|
||||||
}
|
}
|
||||||
|
|
@ -993,28 +992,31 @@ impl WindowDelegate {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_enabled_buttons(&self, buttons: WindowButtons) {
|
pub fn set_enabled_buttons(&self, buttons: WindowButtons) {
|
||||||
let mut mask = self.window().styleMask();
|
let mut mask = self.window().styleMask().0;
|
||||||
|
|
||||||
if buttons.contains(WindowButtons::CLOSE) {
|
if buttons.contains(WindowButtons::CLOSE) {
|
||||||
mask |= NSWindowStyleMaskClosable;
|
mask |= NSWindowStyleMask::Closable.0;
|
||||||
} else {
|
} else {
|
||||||
mask &= !NSWindowStyleMaskClosable;
|
mask &= !NSWindowStyleMask::Closable.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if buttons.contains(WindowButtons::MINIMIZE) {
|
if buttons.contains(WindowButtons::MINIMIZE) {
|
||||||
mask |= NSWindowStyleMaskMiniaturizable;
|
mask |= NSWindowStyleMask::Miniaturizable.0;
|
||||||
} else {
|
} else {
|
||||||
mask &= !NSWindowStyleMaskMiniaturizable;
|
mask &= !NSWindowStyleMask::Miniaturizable.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This must happen before the button's "enabled" status has been set,
|
// This must happen before the button's "enabled" status has been set,
|
||||||
// hence we do it synchronously.
|
// hence we do it synchronously.
|
||||||
self.set_style_mask(mask);
|
self.set_style_mask(NSWindowStyleMask(mask));
|
||||||
|
|
||||||
// We edit the button directly instead of using `NSResizableWindowMask`,
|
// We edit the button directly instead of using `NSResizableWindowMask`,
|
||||||
// since that mask also affect the resizability of the window (which is
|
// since that mask also affect the resizability of the window (which is
|
||||||
// controllable by other means in `winit`).
|
// controllable by other means in `winit`).
|
||||||
if let Some(button) = self.window().standardWindowButton(NSWindowZoomButton) {
|
if let Some(button) = self
|
||||||
|
.window()
|
||||||
|
.standardWindowButton(NSWindowButton::NSWindowZoomButton)
|
||||||
|
{
|
||||||
button.setEnabled(buttons.contains(WindowButtons::MAXIMIZE));
|
button.setEnabled(buttons.contains(WindowButtons::MAXIMIZE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1027,7 +1029,7 @@ impl WindowDelegate {
|
||||||
}
|
}
|
||||||
if self
|
if self
|
||||||
.window()
|
.window()
|
||||||
.standardWindowButton(NSWindowZoomButton)
|
.standardWindowButton(NSWindowButton::NSWindowZoomButton)
|
||||||
.map(|b| b.isEnabled())
|
.map(|b| b.isEnabled())
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
{
|
{
|
||||||
|
|
@ -1131,7 +1133,8 @@ impl WindowDelegate {
|
||||||
// we make it resizable temporarily.
|
// we make it resizable temporarily.
|
||||||
let curr_mask = self.window().styleMask();
|
let curr_mask = self.window().styleMask();
|
||||||
|
|
||||||
let required = NSWindowStyleMaskTitled | NSWindowStyleMaskResizable;
|
let required =
|
||||||
|
NSWindowStyleMask(NSWindowStyleMask::Titled.0 | NSWindowStyleMask::Resizable.0);
|
||||||
let needs_temp_mask = !mask_contains(curr_mask, required);
|
let needs_temp_mask = !mask_contains(curr_mask, required);
|
||||||
if needs_temp_mask {
|
if needs_temp_mask {
|
||||||
self.set_style_mask(required);
|
self.set_style_mask(required);
|
||||||
|
|
@ -1152,12 +1155,13 @@ impl WindowDelegate {
|
||||||
.ivars()
|
.ivars()
|
||||||
.saved_style
|
.saved_style
|
||||||
.take()
|
.take()
|
||||||
.unwrap_or_else(|| self.window().styleMask());
|
.unwrap_or_else(|| self.window().styleMask())
|
||||||
if self.ivars().resizable.get() {
|
.0;
|
||||||
base_mask | NSWindowStyleMaskResizable
|
NSWindowStyleMask(if self.ivars().resizable.get() {
|
||||||
|
base_mask | NSWindowStyleMask::Resizable.0
|
||||||
} else {
|
} else {
|
||||||
base_mask & !NSWindowStyleMaskResizable
|
base_mask & !NSWindowStyleMask::Resizable.0
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is called when the window is exiting fullscreen, whether by the
|
/// This is called when the window is exiting fullscreen, whether by the
|
||||||
|
|
@ -1212,7 +1216,7 @@ impl WindowDelegate {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if mask_contains(self.window().styleMask(), NSWindowStyleMaskResizable) {
|
if mask_contains(self.window().styleMask(), NSWindowStyleMask::Resizable) {
|
||||||
// Just use the native zoom if resizable
|
// Just use the native zoom if resizable
|
||||||
self.window().zoom(None);
|
self.window().zoom(None);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1369,7 +1373,8 @@ impl WindowDelegate {
|
||||||
// set a normal style temporarily. The previous state will be
|
// set a normal style temporarily. The previous state will be
|
||||||
// restored in `WindowDelegate::window_did_exit_fullscreen`.
|
// restored in `WindowDelegate::window_did_exit_fullscreen`.
|
||||||
let curr_mask = self.window().styleMask();
|
let curr_mask = self.window().styleMask();
|
||||||
let required = NSWindowStyleMaskTitled | NSWindowStyleMaskResizable;
|
let required =
|
||||||
|
NSWindowStyleMask(NSWindowStyleMask::Titled.0 | NSWindowStyleMask::Resizable.0);
|
||||||
if !mask_contains(curr_mask, required) {
|
if !mask_contains(curr_mask, required) {
|
||||||
self.set_style_mask(required);
|
self.set_style_mask(required);
|
||||||
self.ivars().saved_style.set(Some(curr_mask));
|
self.ivars().saved_style.set(Some(curr_mask));
|
||||||
|
|
@ -1403,9 +1408,11 @@ impl WindowDelegate {
|
||||||
.save_presentation_opts
|
.save_presentation_opts
|
||||||
.set(Some(app.presentationOptions()));
|
.set(Some(app.presentationOptions()));
|
||||||
|
|
||||||
let presentation_options = NSApplicationPresentationFullScreen
|
let presentation_options = NSApplicationPresentationOptions(
|
||||||
| NSApplicationPresentationHideDock
|
NSApplicationPresentationOptions::NSApplicationPresentationFullScreen.0
|
||||||
| NSApplicationPresentationHideMenuBar;
|
| NSApplicationPresentationOptions::NSApplicationPresentationHideDock.0
|
||||||
|
| NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar.0,
|
||||||
|
);
|
||||||
app.setPresentationOptions(presentation_options);
|
app.setPresentationOptions(presentation_options);
|
||||||
|
|
||||||
let window_level = unsafe { ffi::CGShieldingWindowLevel() } as NSWindowLevel + 1;
|
let window_level = unsafe { ffi::CGShieldingWindowLevel() } as NSWindowLevel + 1;
|
||||||
|
|
@ -1413,9 +1420,9 @@ impl WindowDelegate {
|
||||||
}
|
}
|
||||||
(Some(Fullscreen::Exclusive(ref video_mode)), Some(Fullscreen::Borderless(_))) => {
|
(Some(Fullscreen::Exclusive(ref video_mode)), Some(Fullscreen::Borderless(_))) => {
|
||||||
let presentation_options = self.ivars().save_presentation_opts.get().unwrap_or(
|
let presentation_options = self.ivars().save_presentation_opts.get().unwrap_or(
|
||||||
NSApplicationPresentationFullScreen
|
NSApplicationPresentationOptions(NSApplicationPresentationOptions::NSApplicationPresentationFullScreen.0
|
||||||
| NSApplicationPresentationAutoHideDock
|
| NSApplicationPresentationOptions::NSApplicationPresentationAutoHideDock.0
|
||||||
| NSApplicationPresentationAutoHideMenuBar,
|
| NSApplicationPresentationOptions::NSApplicationPresentationAutoHideMenuBar.0),
|
||||||
);
|
);
|
||||||
app.setPresentationOptions(presentation_options);
|
app.setPresentationOptions(presentation_options);
|
||||||
|
|
||||||
|
|
@ -1455,19 +1462,19 @@ impl WindowDelegate {
|
||||||
|
|
||||||
let new_mask = {
|
let new_mask = {
|
||||||
let mut new_mask = if decorations {
|
let mut new_mask = if decorations {
|
||||||
NSWindowStyleMaskClosable
|
NSWindowStyleMask::Closable.0
|
||||||
| NSWindowStyleMaskMiniaturizable
|
| NSWindowStyleMask::Miniaturizable.0
|
||||||
| NSWindowStyleMaskResizable
|
| NSWindowStyleMask::Resizable.0
|
||||||
| NSWindowStyleMaskTitled
|
| NSWindowStyleMask::Titled.0
|
||||||
} else {
|
} else {
|
||||||
NSWindowStyleMaskBorderless | NSWindowStyleMaskResizable
|
NSWindowStyleMask::Borderless.0 | NSWindowStyleMask::Resizable.0
|
||||||
};
|
};
|
||||||
if !resizable {
|
if !resizable {
|
||||||
new_mask &= !NSWindowStyleMaskResizable;
|
new_mask &= !NSWindowStyleMask::Resizable.0;
|
||||||
}
|
}
|
||||||
new_mask
|
new_mask
|
||||||
};
|
};
|
||||||
self.set_style_mask(new_mask);
|
self.set_style_mask(NSWindowStyleMask(new_mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
@ -1534,8 +1541,8 @@ impl WindowDelegate {
|
||||||
pub fn request_user_attention(&self, request_type: Option<UserAttentionType>) {
|
pub fn request_user_attention(&self, request_type: Option<UserAttentionType>) {
|
||||||
let mtm = MainThreadMarker::from(self);
|
let mtm = MainThreadMarker::from(self);
|
||||||
let ns_request_type = request_type.map(|ty| match ty {
|
let ns_request_type = request_type.map(|ty| match ty {
|
||||||
UserAttentionType::Critical => NSCriticalRequest,
|
UserAttentionType::Critical => NSRequestUserAttentionType::NSCriticalRequest,
|
||||||
UserAttentionType::Informational => NSInformationalRequest,
|
UserAttentionType::Informational => NSRequestUserAttentionType::NSInformationalRequest,
|
||||||
});
|
});
|
||||||
if let Some(ty) = ns_request_type {
|
if let Some(ty) = ns_request_type {
|
||||||
NSApplication::sharedApplication(mtm).requestUserAttention(ty);
|
NSApplication::sharedApplication(mtm).requestUserAttention(ty);
|
||||||
|
|
@ -1602,9 +1609,9 @@ impl WindowDelegate {
|
||||||
fn toggle_style_mask(&self, mask: NSWindowStyleMask, on: bool) {
|
fn toggle_style_mask(&self, mask: NSWindowStyleMask, on: bool) {
|
||||||
let current_style_mask = self.window().styleMask();
|
let current_style_mask = self.window().styleMask();
|
||||||
if on {
|
if on {
|
||||||
self.set_style_mask(current_style_mask | mask);
|
self.set_style_mask(NSWindowStyleMask(current_style_mask.0 | mask.0));
|
||||||
} else {
|
} else {
|
||||||
self.set_style_mask(current_style_mask & (!mask));
|
self.set_style_mask(NSWindowStyleMask(current_style_mask.0 & (!mask.0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1629,9 +1636,9 @@ impl WindowDelegate {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_content_protected(&self, protected: bool) {
|
pub fn set_content_protected(&self, protected: bool) {
|
||||||
self.window().setSharingType(if protected {
|
self.window().setSharingType(if protected {
|
||||||
NSWindowSharingNone
|
NSWindowSharingType::NSWindowSharingNone
|
||||||
} else {
|
} else {
|
||||||
NSWindowSharingReadOnly
|
NSWindowSharingType::NSWindowSharingReadOnly
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1683,12 +1690,14 @@ impl WindowExtMacOS for WindowDelegate {
|
||||||
self.ivars().is_simple_fullscreen.set(true);
|
self.ivars().is_simple_fullscreen.set(true);
|
||||||
|
|
||||||
// Simulate pre-Lion fullscreen by hiding the dock and menu bar
|
// Simulate pre-Lion fullscreen by hiding the dock and menu bar
|
||||||
let presentation_options =
|
let presentation_options = NSApplicationPresentationOptions(
|
||||||
NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar;
|
NSApplicationPresentationOptions::NSApplicationPresentationAutoHideDock.0
|
||||||
|
| NSApplicationPresentationOptions::NSApplicationPresentationAutoHideMenuBar.0,
|
||||||
|
);
|
||||||
app.setPresentationOptions(presentation_options);
|
app.setPresentationOptions(presentation_options);
|
||||||
|
|
||||||
// Hide the titlebar
|
// Hide the titlebar
|
||||||
self.toggle_style_mask(NSWindowStyleMaskTitled, false);
|
self.toggle_style_mask(NSWindowStyleMask::Titled, false);
|
||||||
|
|
||||||
// Set the window frame to the screen frame size
|
// Set the window frame to the screen frame size
|
||||||
let screen = self
|
let screen = self
|
||||||
|
|
@ -1698,8 +1707,8 @@ impl WindowExtMacOS for WindowDelegate {
|
||||||
self.window().setFrame_display(screen.frame(), true);
|
self.window().setFrame_display(screen.frame(), true);
|
||||||
|
|
||||||
// Fullscreen windows can't be resized, minimized, or moved
|
// Fullscreen windows can't be resized, minimized, or moved
|
||||||
self.toggle_style_mask(NSWindowStyleMaskMiniaturizable, false);
|
self.toggle_style_mask(NSWindowStyleMask::Miniaturizable, false);
|
||||||
self.toggle_style_mask(NSWindowStyleMaskResizable, false);
|
self.toggle_style_mask(NSWindowStyleMask::Resizable, false);
|
||||||
self.window().setMovable(false);
|
self.window().setMovable(false);
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
@ -1793,7 +1802,7 @@ impl WindowExtMacOS for WindowDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mask_contains(mask: NSWindowStyleMask, value: NSWindowStyleMask) -> bool {
|
fn mask_contains(mask: NSWindowStyleMask, value: NSWindowStyleMask) -> bool {
|
||||||
mask & value == value
|
mask.0 & value.0 == value.0
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_STANDARD_FRAME: NSRect =
|
const DEFAULT_STANDARD_FRAME: NSRect =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue