objc2_core_graphics/generated/
CGWindow.rs1use core::ptr::NonNull;
4#[cfg(feature = "objc2")]
5use objc2::__framework_prelude::*;
6use objc2_core_foundation::*;
7
8use crate::*;
9
10pub const kCGNullWindowID: CGWindowID = 0;
12pub type CGWindowID = u32;
14
15#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct CGWindowSharingType(pub u32);
20impl CGWindowSharingType {
21 #[doc(alias = "kCGWindowSharingNone")]
22 pub const None: Self = Self(0);
23 #[doc(alias = "kCGWindowSharingReadOnly")]
24 pub const ReadOnly: Self = Self(1);
25 #[doc(alias = "kCGWindowSharingReadWrite")]
26 pub const ReadWrite: Self = Self(2);
27}
28
29#[cfg(feature = "objc2")]
30unsafe impl Encode for CGWindowSharingType {
31 const ENCODING: Encoding = u32::ENCODING;
32}
33
34#[cfg(feature = "objc2")]
35unsafe impl RefEncode for CGWindowSharingType {
36 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39#[repr(transparent)]
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct CGWindowBackingType(pub u32);
44impl CGWindowBackingType {
45 #[doc(alias = "kCGBackingStoreRetained")]
46 pub const BackingStoreRetained: Self = Self(0);
47 #[doc(alias = "kCGBackingStoreNonretained")]
48 pub const BackingStoreNonretained: Self = Self(1);
49 #[doc(alias = "kCGBackingStoreBuffered")]
50 pub const BackingStoreBuffered: Self = Self(2);
51}
52
53#[cfg(feature = "objc2")]
54unsafe impl Encode for CGWindowBackingType {
55 const ENCODING: Encoding = u32::ENCODING;
56}
57
58#[cfg(feature = "objc2")]
59unsafe impl RefEncode for CGWindowBackingType {
60 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
61}
62
63extern "C" {
64 pub static kCGWindowNumber: &'static CFString;
66}
67
68extern "C" {
69 pub static kCGWindowStoreType: &'static CFString;
71}
72
73extern "C" {
74 pub static kCGWindowLayer: &'static CFString;
76}
77
78extern "C" {
79 pub static kCGWindowBounds: &'static CFString;
81}
82
83extern "C" {
84 pub static kCGWindowSharingState: &'static CFString;
86}
87
88extern "C" {
89 pub static kCGWindowAlpha: &'static CFString;
91}
92
93extern "C" {
94 pub static kCGWindowOwnerPID: &'static CFString;
96}
97
98extern "C" {
99 pub static kCGWindowMemoryUsage: &'static CFString;
101}
102
103extern "C" {
104 #[deprecated = "No longer supported"]
106 pub static kCGWindowWorkspace: &'static CFString;
107}
108
109extern "C" {
110 pub static kCGWindowOwnerName: &'static CFString;
112}
113
114extern "C" {
115 pub static kCGWindowName: &'static CFString;
117}
118
119extern "C" {
120 pub static kCGWindowIsOnscreen: &'static CFString;
122}
123
124extern "C" {
125 pub static kCGWindowBackingLocationVideoMemory: &'static CFString;
127}
128
129#[repr(transparent)]
132#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
133pub struct CGWindowListOption(pub u32);
134bitflags::bitflags! {
135 impl CGWindowListOption: u32 {
136 #[doc(alias = "kCGWindowListOptionAll")]
137 const OptionAll = 0;
138 #[doc(alias = "kCGWindowListOptionOnScreenOnly")]
139 const OptionOnScreenOnly = 1<<0;
140 #[doc(alias = "kCGWindowListOptionOnScreenAboveWindow")]
141 const OptionOnScreenAboveWindow = 1<<1;
142 #[doc(alias = "kCGWindowListOptionOnScreenBelowWindow")]
143 const OptionOnScreenBelowWindow = 1<<2;
144 #[doc(alias = "kCGWindowListOptionIncludingWindow")]
145 const OptionIncludingWindow = 1<<3;
146 #[doc(alias = "kCGWindowListExcludeDesktopElements")]
147 const ExcludeDesktopElements = 1<<4;
148 }
149}
150
151#[cfg(feature = "objc2")]
152unsafe impl Encode for CGWindowListOption {
153 const ENCODING: Encoding = u32::ENCODING;
154}
155
156#[cfg(feature = "objc2")]
157unsafe impl RefEncode for CGWindowListOption {
158 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
159}
160
161#[inline]
162pub extern "C-unwind" fn CGWindowListCopyWindowInfo(
163 option: CGWindowListOption,
164 relative_to_window: CGWindowID,
165) -> Option<CFRetained<CFArray>> {
166 extern "C-unwind" {
167 fn CGWindowListCopyWindowInfo(
168 option: CGWindowListOption,
169 relative_to_window: CGWindowID,
170 ) -> Option<NonNull<CFArray>>;
171 }
172 let ret = unsafe { CGWindowListCopyWindowInfo(option, relative_to_window) };
173 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
174}
175
176#[inline]
177pub extern "C-unwind" fn CGWindowListCreate(
178 option: CGWindowListOption,
179 relative_to_window: CGWindowID,
180) -> Option<CFRetained<CFArray>> {
181 extern "C-unwind" {
182 fn CGWindowListCreate(
183 option: CGWindowListOption,
184 relative_to_window: CGWindowID,
185 ) -> Option<NonNull<CFArray>>;
186 }
187 let ret = unsafe { CGWindowListCreate(option, relative_to_window) };
188 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
189}
190
191#[inline]
195pub unsafe extern "C-unwind" fn CGWindowListCreateDescriptionFromArray(
196 window_array: Option<&CFArray>,
197) -> Option<CFRetained<CFArray>> {
198 extern "C-unwind" {
199 fn CGWindowListCreateDescriptionFromArray(
200 window_array: Option<&CFArray>,
201 ) -> Option<NonNull<CFArray>>;
202 }
203 let ret = unsafe { CGWindowListCreateDescriptionFromArray(window_array) };
204 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
205}
206
207#[repr(transparent)]
210#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
211pub struct CGWindowImageOption(pub u32);
212bitflags::bitflags! {
213 impl CGWindowImageOption: u32 {
214 #[doc(alias = "kCGWindowImageDefault")]
215 const Default = 0;
216 #[doc(alias = "kCGWindowImageBoundsIgnoreFraming")]
217 const BoundsIgnoreFraming = 1<<0;
218 #[doc(alias = "kCGWindowImageShouldBeOpaque")]
219 const ShouldBeOpaque = 1<<1;
220 #[doc(alias = "kCGWindowImageOnlyShadows")]
221 const OnlyShadows = 1<<2;
222 #[doc(alias = "kCGWindowImageBestResolution")]
223 const BestResolution = 1<<3;
224 #[doc(alias = "kCGWindowImageNominalResolution")]
225 const NominalResolution = 1<<4;
226 }
227}
228
229#[cfg(feature = "objc2")]
230unsafe impl Encode for CGWindowImageOption {
231 const ENCODING: Encoding = u32::ENCODING;
232}
233
234#[cfg(feature = "objc2")]
235unsafe impl RefEncode for CGWindowImageOption {
236 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
237}
238
239#[cfg(feature = "CGImage")]
240#[deprecated = "Please use ScreenCaptureKit instead."]
241#[inline]
242pub extern "C-unwind" fn CGWindowListCreateImage(
243 screen_bounds: CGRect,
244 list_option: CGWindowListOption,
245 window_id: CGWindowID,
246 image_option: CGWindowImageOption,
247) -> Option<CFRetained<CGImage>> {
248 extern "C-unwind" {
249 fn CGWindowListCreateImage(
250 screen_bounds: CGRect,
251 list_option: CGWindowListOption,
252 window_id: CGWindowID,
253 image_option: CGWindowImageOption,
254 ) -> Option<NonNull<CGImage>>;
255 }
256 let ret =
257 unsafe { CGWindowListCreateImage(screen_bounds, list_option, window_id, image_option) };
258 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
259}
260
261#[cfg(feature = "CGImage")]
265#[deprecated = "Please use ScreenCaptureKit instead."]
266#[inline]
267pub unsafe extern "C-unwind" fn CGWindowListCreateImageFromArray(
268 screen_bounds: CGRect,
269 window_array: &CFArray,
270 image_option: CGWindowImageOption,
271) -> Option<CFRetained<CGImage>> {
272 extern "C-unwind" {
273 fn CGWindowListCreateImageFromArray(
274 screen_bounds: CGRect,
275 window_array: &CFArray,
276 image_option: CGWindowImageOption,
277 ) -> Option<NonNull<CGImage>>;
278 }
279 let ret =
280 unsafe { CGWindowListCreateImageFromArray(screen_bounds, window_array, image_option) };
281 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
282}
283
284#[inline]
285pub extern "C-unwind" fn CGPreflightScreenCaptureAccess() -> bool {
286 extern "C-unwind" {
287 fn CGPreflightScreenCaptureAccess() -> bool;
288 }
289 unsafe { CGPreflightScreenCaptureAccess() }
290}
291
292#[inline]
293pub extern "C-unwind" fn CGRequestScreenCaptureAccess() -> bool {
294 extern "C-unwind" {
295 fn CGRequestScreenCaptureAccess() -> bool;
296 }
297 unsafe { CGRequestScreenCaptureAccess() }
298}