objc2_app_kit/generated/
NSScreen.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-foundation")]
6use objc2_core_foundation::*;
7use objc2_foundation::*;
8#[cfg(feature = "objc2-quartz-core")]
9#[cfg(target_vendor = "apple")]
10use objc2_quartz_core::*;
11
12use crate::*;
13
14extern_class!(
15    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscreen?language=objc)
16    #[unsafe(super(NSObject))]
17    #[thread_kind = MainThreadOnly]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    pub struct NSScreen;
20);
21
22unsafe impl NSObjectProtocol for NSScreen {}
23
24impl NSScreen {
25    extern_methods!(
26        #[unsafe(method(screens))]
27        #[unsafe(method_family = none)]
28        pub fn screens(mtm: MainThreadMarker) -> Retained<NSArray<NSScreen>>;
29
30        #[unsafe(method(mainScreen))]
31        #[unsafe(method_family = none)]
32        pub fn mainScreen(mtm: MainThreadMarker) -> Option<Retained<NSScreen>>;
33
34        #[unsafe(method(deepestScreen))]
35        #[unsafe(method_family = none)]
36        pub unsafe fn deepestScreen(mtm: MainThreadMarker) -> Option<Retained<NSScreen>>;
37
38        #[unsafe(method(screensHaveSeparateSpaces))]
39        #[unsafe(method_family = none)]
40        pub unsafe fn screensHaveSeparateSpaces(mtm: MainThreadMarker) -> bool;
41
42        #[cfg(feature = "NSGraphics")]
43        #[unsafe(method(depth))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn depth(&self) -> NSWindowDepth;
46
47        #[unsafe(method(frame))]
48        #[unsafe(method_family = none)]
49        pub fn frame(&self) -> NSRect;
50
51        #[unsafe(method(visibleFrame))]
52        #[unsafe(method_family = none)]
53        pub fn visibleFrame(&self) -> NSRect;
54
55        #[cfg(feature = "NSGraphics")]
56        #[unsafe(method(deviceDescription))]
57        #[unsafe(method_family = none)]
58        pub fn deviceDescription(
59            &self,
60        ) -> Retained<NSDictionary<NSDeviceDescriptionKey, AnyObject>>;
61
62        #[cfg(feature = "NSColorSpace")]
63        #[unsafe(method(colorSpace))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn colorSpace(&self) -> Option<Retained<NSColorSpace>>;
66
67        #[cfg(feature = "NSGraphics")]
68        #[unsafe(method(supportedWindowDepths))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn supportedWindowDepths(&self) -> NonNull<NSWindowDepth>;
71
72        #[cfg(feature = "NSGraphics")]
73        #[unsafe(method(canRepresentDisplayGamut:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn canRepresentDisplayGamut(&self, display_gamut: NSDisplayGamut) -> bool;
76
77        #[unsafe(method(convertRectToBacking:))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn convertRectToBacking(&self, rect: NSRect) -> NSRect;
80
81        #[unsafe(method(convertRectFromBacking:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn convertRectFromBacking(&self, rect: NSRect) -> NSRect;
84
85        #[unsafe(method(backingAlignedRect:options:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn backingAlignedRect_options(
88            &self,
89            rect: NSRect,
90            options: NSAlignmentOptions,
91        ) -> NSRect;
92
93        #[cfg(feature = "objc2-core-foundation")]
94        #[unsafe(method(backingScaleFactor))]
95        #[unsafe(method_family = none)]
96        pub fn backingScaleFactor(&self) -> CGFloat;
97
98        #[unsafe(method(localizedName))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn localizedName(&self) -> Retained<NSString>;
101
102        #[unsafe(method(safeAreaInsets))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn safeAreaInsets(&self) -> NSEdgeInsets;
105
106        #[unsafe(method(auxiliaryTopLeftArea))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn auxiliaryTopLeftArea(&self) -> NSRect;
109
110        #[unsafe(method(auxiliaryTopRightArea))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn auxiliaryTopRightArea(&self) -> NSRect;
113    );
114}
115
116/// Methods declared on superclass `NSObject`.
117impl NSScreen {
118    extern_methods!(
119        #[unsafe(method(init))]
120        #[unsafe(method_family = init)]
121        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
122
123        #[unsafe(method(new))]
124        #[unsafe(method_family = new)]
125        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
126    );
127}
128
129extern "C" {
130    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscreencolorspacedidchangenotification?language=objc)
131    pub static NSScreenColorSpaceDidChangeNotification: &'static NSNotificationName;
132}
133
134impl NSScreen {
135    extern_methods!(
136        #[cfg(feature = "objc2-core-foundation")]
137        #[unsafe(method(maximumExtendedDynamicRangeColorComponentValue))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn maximumExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;
140
141        #[cfg(feature = "objc2-core-foundation")]
142        #[unsafe(method(maximumPotentialExtendedDynamicRangeColorComponentValue))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn maximumPotentialExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;
145
146        #[cfg(feature = "objc2-core-foundation")]
147        #[unsafe(method(maximumReferenceExtendedDynamicRangeColorComponentValue))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn maximumReferenceExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;
150    );
151}
152
153impl NSScreen {
154    extern_methods!(
155        /// The maximum frames per second this screen supports.
156        #[unsafe(method(maximumFramesPerSecond))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn maximumFramesPerSecond(&self) -> NSInteger;
159
160        /// The minimum refresh interval this screen supports, in seconds.
161        ///
162        /// This is the shortest amount of time a frame will be present on screen.
163        /// minimumRefreshInterval and maximumRefreshInterval will be the same for displays that do not support variable refresh rates.
164        #[unsafe(method(minimumRefreshInterval))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn minimumRefreshInterval(&self) -> NSTimeInterval;
167
168        /// The maximum refresh interval this screen supports, in seconds.
169        ///
170        /// minimumRefreshInterval and maximumRefreshInterval will be the same for displays that do not support variable refresh rates.
171        #[unsafe(method(maximumRefreshInterval))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn maximumRefreshInterval(&self) -> NSTimeInterval;
174
175        /// The update granularity of the screen's current mode, in seconds.
176        ///
177        /// The display will update at the next boundary defined by the granularity, after the minimum refresh interval has been reached. When 0, the display can update at any time between the minimum and maximum refresh rate intervals of the screen. Fixed refresh rate screen modes will return the refresh interval as the update granularity (e.g. 16.66ms for 60Hz refresh rates), meaning updates only occur at refresh rate boundaries.
178        #[unsafe(method(displayUpdateGranularity))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn displayUpdateGranularity(&self) -> NSTimeInterval;
181
182        /// The time at which the last framebuffer update occurred on the display, in seconds since startup that the system has been awake.
183        #[unsafe(method(lastDisplayUpdateTimestamp))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn lastDisplayUpdateTimestamp(&self) -> NSTimeInterval;
186    );
187}
188
189/// NSDisplayLink.
190impl NSScreen {
191    extern_methods!(
192        #[cfg(feature = "objc2-quartz-core")]
193        #[cfg(target_vendor = "apple")]
194        #[unsafe(method(displayLinkWithTarget:selector:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn displayLinkWithTarget_selector(
197            &self,
198            target: &AnyObject,
199            selector: Sel,
200        ) -> Retained<CADisplayLink>;
201    );
202}
203
204/// NSDeprecated.
205impl NSScreen {
206    extern_methods!(
207        #[cfg(feature = "objc2-core-foundation")]
208        #[deprecated = "Use -convertRectToBacking: or -backingScaleFactor instead"]
209        #[unsafe(method(userSpaceScaleFactor))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn userSpaceScaleFactor(&self) -> CGFloat;
212    );
213}